Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
How to surround jinja expression with curly brackets?
A jinja template expression starts and ends with double curly brackets, which the templating engine consumes. But what if you need a single pair of curly brackets left in the output?
Something like this: {{{ jinja_expression }}}
--> {jinja_output}
Of course the above doesn't work because jinja will think that the two outermost brackets are for it.
1 answer
The following users marked this post as Works for me:
User | Comment | Date |
---|---|---|
Iizuki | (no comment) | Mar 22, 2024 at 06:33 |
You can separate the curly brackets with spaces, and instruct jinja to remove them afterwards: { {{- jinja_expression -}} }
. That way the outer curly brackets are left untouched.
The minus signs strip whitespace from their respective sides of the template. It's briefly mentioned in the documentation.
0 comment threads