stencilproject/Stencil

Question: Is there a way to nest tags

otusweb opened this issue · 1 comments

I'm trying to create a stencil for a document that consists of two columns and where I want the left column to be left justify and the right column right justified. ie:

abcd     efgh
abc       fgh
abcd     efgh
abc       fgh 

I could write a custom tag that would take the width of the page and the two parameters and this would work fine.
The problem I run into is that each string would itself need to be a tag/variable (the left side are localised strings, the right side is data coming from app.

Any idea on how to do this?

djbe commented

I don't see why the parameters of your tag/filter/… can't be variables. See for example the for tag, it accepts both constants & variables:

{% for item in myArray %}…{% endfor %}

{% for item in 1...3 %}…{% endfor %}

So if you have a custom tag, you could accept multiple parameters, mixes of constants and variables. See the call tag in StencilSwiftKit:

{% call myMacro "myString" myVariable "someOtherString" %}