Skip to content
Advertisement

Tag: jinja2

Ansible write variables into YAML file

I have a specific ansible variable structure that I want to get from the vault into a yaml file on my hosts. Lets assume a structure like this: I need something like a “generic” template to output whatever “secrets” contains at the moment, since the content changes almost completely based on the current environment. The easiest solution I can think

Sort dict in jinja2 loop

I’m still learning jinja2 and flask and I’m having a difficulty using dictsort in jinja2. So I’m passing this dict into a jinja2 template: What I want is create a table that is sorted by the value of the key ‘totalpts’. I tried all sort of things and it just doesn’t take totalpts into account when “sorting”. Here’s one of

Pass variables to Flask’s render_template

I want to pass multiple variables from my Flask view to my Jinja template. Right now, I can only pass one. How do I pass multiple variable when rendering a template? Answer The render_template function takes any number of keyword arguments. Query for each of the things you need in the template, then pass the results of each query as

Insert static files literally into Jinja templates without parsing them

I’m trying to insert file into a page using Jinja 2.6 using the include tag. This worked fine until I started using characters in the file that are reminiscent of the Jinja syntax, at which point it realized it couldn’t parse them and bombed. Short of going though the file and escaping all characters, what can I do to tell

Advertisement