cider
cider copied to clipboard
Add custom variables for reuse across templates
This PR is an attempt to add basic custom variables which can be reused across templates. These should be named with a valid identifier, and then can be substitued in templates by using {{ variables.my-variable }}
. These work in both the HTML and CSS parts of the template.
Example usage
Say you wish to use a specific color to represent a certain class of cards (ie. a Fighter). This colour should be used as the back of the card, as the border on the front of the card, and to colour the text on other cards referencing that type. Custom Variables would allow you to specify the color once and reuse it over any template you wish.
You'd first add a variable named fighter-color
with a value of #f00
. then you could use {{ variables.fighter-color }}
anywhere you need to in both the template's html and the css (ie for the back of the card something like .card { background-color: {{ variables.fighter-color }}; }
)
Limitations
This is a really quick basic implementation, just to see if it's something you're interested in. Some enhancements that I think would be required are:
-
Name
validation: Names need to be valid identifiers.my-variable
,myvariable
,MyVariable
are all fine;my variable
won't work but is currently permitted in the ui - Uniqueness: Names should really be unique, as is it's possible to add multiple variables with the same name. Currently duplicate variables will overwrite previous versions, which could cause confusion