Allows you to render variables within
templateData using text elements
Install this DocPad plugin by entering
docpad install text into your terminal.
If you have this in your
templateData:firstname: 'Benjamin'lastname: 'Lupton'fullname: '<t>firstname</t> <t>lastname</t>'markdownExample: '<t render="markdown">this is so **awesome**</t>'markdownEcoExample: '<t render="html.md.eco">here is a random number: **<%- Math.random() %>**</t>'
Doing the following inside a document:
My creator's firstname is: firstnameMy creator's lastname is: lastnameMy creator's fullname is: fullnameThe markdown example is: markdownExampleThe markdown eco example is: markdownEcoExample
My creator's firstname is: BenjaminMy creator's lastname is: LuptonMy creator's fullname is: Benjamin LuptonThe markdown example is: this is so awesomeThe markdown eco example is: here is a random number: 0.5123213213123
Which is incredibly useful for abstracting out common generic pieces of text from your templates and placing them inside your configuration files. A common use case for this is easy configurability of skeletons, as well as easier translation of your website.
If you are embedding a text block into a text block, it is best that you name your text block like so
<t:myName>blah</t:myName> that way our parser won't get confused as easily :)
Alternatively, you can use the
t template helper like so
What regex string should we use to find text elements. The default value will find
<text> elements. If you use SVG, you may want to change this just to
t to avoid conflicts with the
What element should be preferred when we are inject text elements with the
t template helper? The default value will inject
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:
Unless stated otherwise all works are:
and licensed under: