
Jinja 2.10 - stablemap
https://github.com/pallets/jinja/releases/tag/2.10
======
the_mitsuhiko
The native environment should help ansible users a lot. As far as I know this
will unblock quite a few issues that are currently open against ansible.

What it does:
[http://jinja.pocoo.org/docs/2.10/nativetypes/](http://jinja.pocoo.org/docs/2.10/nativetypes/)

~~~
koolba
What’s a sample use case for this? A Python-ish VM to eval user supplied
expressions?

~~~
the_mitsuhiko
Ansible generates out a lot of yaml and uses jinja for expressions.

~~~
xorcist
While the changes in Jinja are welcome, maybe, just maybe, Ansible should
consider not using yaml for absolutely everything. There can be more sensible
ways to store data sometimes. Just saying.

~~~
Jedd
> ... maybe, Ansible should consider not using yaml for absolutely everything.

Maybe. But what problems with Ansible are you trying to solve by using
additional, and perhaps domain specific, languages?

I haven't used Ansible, but I do use SaltStack, which also relies on YAML, and
also uses Jinja, hence my interest here.

SaltStack, and I'm assuming Ansible can do this too, will happily use whatever
you want, even raw python, as state (configuration) files, so long as they can
generate yaml.

This is not as inelegant as it sounds :) -- it means configuration length &
complexity can be represented by (or hidden behind) short, palatable
algorithms.

As soon as the suggestion is made to introduce yet another DSL to a system,
you end up with holy wars about which one, and then a total mess trying to
integrate and support both.

Anyway, if you don't want to use YAML / Jinja, then eschew SaltStack, Ansible
etc in favour of Chef, Puppet, SCCM, etc.

~~~
mattbillenstein
You can use mako in salt, I haven't had any issues with it at all.

~~~
the_mitsuhiko
Mako and Jinja (until this release) really did not differ all that much with
regards to this feature. However the ansible community outlined enough reasons
for why they are interested in this.

------
yoavm
I wish Python had more templating engines like Jade (now Pug), Slim & HAML. I
can't go back to writing HTML anymore. I know about PyJade but it's (and all
it's forks) seems always highly unmaintained.

------
mattbillenstein
I must say, I almost always try to swap in Mako for Jinja -- instead of
learning yet another DSL for templating, I can just use a very good language I
already know in my templates: Python.

~~~
iamgopal
You know Jinja compiles template in to python code, right ?

~~~
mattbillenstein
Yeah, what is your point?

------
sigjuice
For those of us unfamiliar with this stuff, would it be accurate think of a
"template engine" as a sophisticated "printf"?

~~~
dangerbird2
A templating engine does a few things differently than printf. Typically, it
will compile into an intermediate version, for scripting languages like python
as a module or object in the language. Most importantly, it escapes the input
to prevent arbitrary HTML injection, for example a user inserting a <script>
tag in a blog post content causing the javascript to be evaluated. Often,
template engines have features for making it easier to design web user
interfaces such as template inherritence and composition so you can share
things like layouts, headers, and menus across pages.

~~~
sametmax
+1. It can deal with non dev creating templates. It can compose templates.
Manage caching. Embed logic. Debugging.

------
nzjrs
I wonder if the new namespaces objects can be (ab)used to return state from
macros.

