Add custom variables for reuse across templates #100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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