Skip to content

Instantly share code, notes, and snippets.

@MrStonedOne MrStonedOne/code.dm
Created Dec 30, 2018

Embed
What would you like to do?
object defined template language preview
/client/verb/Display_Tokens()
var/list/characterMappings = list()
for (var/type in typesof(/datum/templateToken))
var/datum/templateToken/tType = type
var/character = initial(tType.character)
var/word = initial(tType.word)
if (isnull(character))
continue
var/list/characterMapping = characterMappings["[character]"]
if (!characterMapping)
characterMapping = (characterMappings["[character]"] = list())
characterMapping[word] = tType
world.log << json_encode(characterMappings)
/datum/templateToken
//instance vars
//--snip--
//parser vars (compile time values only)
//what starting character does this token listen for, empty string for default, null to disable parsing
var/character
//what word (after the starting character) does this token listen for.
//empty string to cover blank tokens, null for wildcard/default.
var/word
{
"!":{
null:"/datum/templateToken/TStringLiteral/TEscapedVariable"
},
"%":{
null:"/datum/templateToken/TVariable/Updating",
"":"/datum/templateToken/TConditional/TUpdatingBlock"
},
"$":{
null:"/datum/templateToken/TVariable/HTMLSanitize"
},
"&":{
null:"/datum/templateToken/TVariable/URLSanitize"
},
"*":{
null:"/datum/templateToken/TVariable/NoSanitize"
},
"":{
null:"/datum/templateToken/TVariable"
},
"/":{
null:"/datum/templateToken/TClosure"
},
"#":{
"default":"/datum/templateToken/TConditional/TElse/TDefault",
"else":"/datum/templateToken/TConditional/TElse",
"foreach":"/datum/templateToken/TConditional/TIfEmpty/TIfnEmpty/TForEach",
"!ifempty":"/datum/templateToken/TConditional/TIfEmpty/TIfnEmpty/Reversed",
"ifempty!":"/datum/templateToken/TConditional/TIfEmpty/TIfnEmpty",
"ifempty":"/datum/templateToken/TConditional/TIfEmpty",
"!if":"/datum/templateToken/TConditional/TIf/TIfn/Reversed",
"if!":"/datum/templateToken/TConditional/TIf/TIfn",
"if":"/datum/templateToken/TConditional/TIf",
"switch":"/datum/templateToken/TConditional/TSwitch"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.