cykerway / jinja-cli

a command line interface to jinja;
https://repo.cykerway.com/jinja-cli
GNU General Public License v3.0
29 stars 9 forks source link

chainable variable #9

Closed matuskosut closed 2 years ago

matuskosut commented 2 years ago

Hi,

what is the expected functionality of --undefined chainable?

Currently it works for me same way as --undefined '' - undefined variables get replaced with an empty string (removed).

I would expect there to be an option where undefined values stay untouched (template.txt):

Example template {{ NAME }}

Config option {{ VALUE }}

Running a command like this: NAME=Joe jinja -E NAME --undefined chainable template.txt would result in something like this:

Example template Joe

Config option {{ VALUE }}
cykerway commented 2 years ago

jinja-cli is merely a thin client. Its README has a link to Jinja's undefined variables.

For chainable, see https://jinja.palletsprojects.com/en/latest/api/#jinja2.ChainableUndefined

What you want is "an undefined that returns its name when printed", but I don't see where Jinja provides such a thing. Of course you can open an issue to see if they will add it.

matuskosut commented 2 years ago

@cykerway thanks! you are right.