HubSpot / jinjava

Jinja template engine for Java
Apache License 2.0
690 stars 168 forks source link

Is the expression interpolation recursive? #1113

Closed s666p closed 1 year ago

s666p commented 1 year ago

Hello everyone. It is very important for my project to use a template engine that recursively renders expression pointing to other expression.

For example, we have the following context:

name->{{key1}}
key1->{{key2}}
key2->Jared

and this template: Hello {{name}}

I need the following recursive behavior:

render(name) 
--> render(key1) 
----> render(key2)

and don't want this iterative one:

Hello {{name}}->Hello {{key1}}
Hello {{key1}}->Hello {{key2}}
Hello {{key2}}->Hello Jared

Could you please tell me which of these two types of rendering is used in Jinjava?

jasmith-hs commented 1 year ago

By default that functionality is turned on. It is called nested interpretation. It can be turned off with this config builder method: https://github.com/HubSpot/jinjava/blob/15f33ad9a3b97f3e1aa86e9f9bc7aa6547feecb1/src/main/java/com/hubspot/jinjava/JinjavaConfig.java#L447-L450