I’ve been working through a sticky problem with Djolt, trying to implement my Toronto Fires example in as few lines as possible. As part of this, I’ve come up with the idea of adding indirection to Djolt templates:
import djolt
d = {
"a" : "It says: {{ b }}",
"b" : "Hello, World"
}
t = djolt.Template("""
a: {{ a }}
b: {{ b }}
*a: {{ *a }}
""")
print t.Render(d)
""")
print t.Render(d)
Which yields:
a: It says: {{ b }}
b: Hello, World
*a: It says: Hello, World
This is significantly updated from the original version I posted here an hour ago. The indirection now makes the variable read as a template. This is a much more powerful concept.
[...] If you want to see the HTML template that drives the application it is here. Note two variations from Django templates: the {% asis %} block which doesn’t intrepret it’s content as Djolt code and the {{ *paramd.template|safe }} variable which interprets the variable’s contents as a template. [...]