Vibe.d diet template reuse

Jot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 2 22:31:21 PDT 2016


I would like to create some generic diet templates for different 
html functionality.

Some code in the template will need to be setup/changed for it to 
function properly.

How can I write code that allows for one to express generic 
statements in the template but access/modify them in another 
template?

Is there a way to pass around a context, including functional 
code between templates?

e.g., I might want to create a d function in a diet template that 
will be used in generating another template.

e.g. (pseudo),

block
    -auto MyFunc(int x) { return 3*x; }
    include test

....

test.dt:

block
    -for(i; 1..MyFunc(3))
       ...


having such a feature allows me to generalize my templates quite 
a bit and reuse them for various html features rather than 
duplicating the majority of the code but I need a way to pass 
some unspecified functionality to a template before instantiation.





More information about the Digitalmars-d-learn mailing list