Replies: 1 comment 1 reply
-
You could use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello community,
First of all, thank you for developing and maintaining jinja2.
I need your help :-)
I have a template:
some text {{ a }} more text {{ b + 1 }} text text {{ b + c.d }}
I want to achieve the following behavior:
Render the expression if it can be resolved, otherwise just leave it there, so I can render it later, in the next stage.
For example, with
a=3
, andb
left undefined, I need the following result:some text 3 more text {{ b + 1 }} text text {{ b + c.d }}
Is there any straightforward way to achieve this behavior?
I tried subclassing
class Undefined
, but the problem is, I only have access to the missing variable name, and not the whole expression.I tried doing the steps in
Template.render()
manually (parse, generate, compile), to understand what is actually happening behind the scenes. Before trying to subclassclass CodeGenerator
, I wanted to ask if there was a better way to achieve that.Thank you.
Beta Was this translation helpful? Give feedback.
All reactions