Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template system compatibility? #5

Open
shawnbot opened this issue Feb 3, 2015 · 1 comment
Open

Template system compatibility? #5

shawnbot opened this issue Feb 3, 2015 · 1 comment

Comments

@shawnbot
Copy link
Owner

shawnbot commented Feb 3, 2015

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" }}
@shawnbot
Copy link
Owner Author

shawnbot commented Feb 3, 2015

Of course, it's also possible to ignore the default and/or tertiary operator syntax altogether and just ask template authors to write:

{% if foo %}{{ foo }}{% else %}bar{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant