HubSpot / jinjava

Jinja template engine for Java
Apache License 2.0
704 stars 169 forks source link

What value in default filter is supported? #424

Open feli5 opened 4 years ago

feli5 commented 4 years ago

I want to use default filter to set default values when value is not defined. But seems dict and list of default is not supported

In below case when resources.lbs is not defined, will still output content in for loop

{% for lb in resources.lbs|default({}) %} do some thing {% endfor %}

In below case when resources.lbs is not defined, will not output content in for loop

{% if resources.lbs is not defined %} {% set lbs = {} %} {% else %} {% set lbs = resources.lbs %} {% endif %} {% for lb in lbs %} do some thing {% endfor %}

feli5 commented 4 years ago
    <dependency>
        <groupId>com.hubspot.jinjava</groupId>
        <artifactId>jinjava</artifactId>
        <version>2.4.8</version>
    </dependency>
feli5 commented 4 years ago
    <dependency>
        <groupId>com.hubspot.jinjava</groupId>
        <artifactId>jinjava</artifactId>
        <version>2.4.8</version>
    </dependency>

Version of jinjava