mmontone / djula

Common Lisp port of the Django templating language
http://mmontone.github.io/djula/djula
MIT License
152 stars 21 forks source link

Question: replacing a placeholder in a placeholder? #56

Closed vindarel closed 4 years ago

vindarel commented 4 years ago

I have a text variable that uses other variable placeholders:

;; var1
      <li> {{ contact.phone }} </li>

This var1 is rendered in the template literally, the contact.phone variable is not replaced:

{{ var1 }}
=>
      <li> {{ contact.phone }} </li>
;; instead of
0098 9 8 7…

This is the expected behaviour.

But maybe is there a Djula trick to make it re-evaluate the rendered text?

With simple variables like this I can still render var1 differently with a match and replace, even though it is less practical, but as soon as there are conditionals and other template tags, we'll want Djula's machinery.

      {% if contact.phone %}
      <li> {{ phone }} </li>
      {% endif %}

thanks

edit: looks totally like I should use templates now… looking into that.