shawnbot/stag

Template system compatibility?

Open

#5 aperta il 3 feb 2015

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)JavaScript (2 fork)github user discovery
help wanted

Metriche repository

Star
 (15 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

There are some subtle and not-so-subtle variations in the different implementations of Django-style templates. For instance, default values in Django look like this, which is really just a holdover from Smarty:

{{ foo|default:"bar" }}

Whereas Jinja (and Nunjucks, which followed its lead) uses the function-style syntax:

{{ foo|default("bar") }}

I'm inclined to go with the Jinja syntax since Django can be made to work with Jinja templates, but not vice-versa. The goal here isn't necessarily full cross-compatibility of templates between systems, but I'd like to avoid anything proprietary to Nunjucks that would make it difficult to make a move (or at least a port) to Python, for instance, at a later date. It may also be possible to standardize on the form:

{{ foo and foo or "bar" }}

Guida contributor