New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support {% set %}
statements
#68
Comments
I would be curious to see how you use it. I'm generally feeling these days that |
Part the reason I wanted this feature probably comes from from porting some code my own preprocessing code to minijina in the most direct way as possible. I'm not overly familiar with templating languages in general, and I have mostly just been using it a simple preprocessor, so I could be missing something simple here. First to reuse the result of a complicated expression in multiple places:
Second, building flags from optional parameters:
The first case is no longer much of an issue thanks to #66 and the second case is fairly straightforward to solve by just chaining all the expressions together. Overall, I don't really have a strong need -- I just looked at the Jinja reference for a feature that would work for what I wanted and wondered why it didn't exist. |
I would like to have That and I need to research how Jinja handles set - are they global or scoped? |
It shouldn't be too hard to implement. Just requires some refactoring on the scopes. I already simplified this a bit now with the introduction of unpacking in the |
Nice! A usecase for this is I am working on parsing files, similar to how dbt does (which uses Python/jinja). dbt uses It looks like this:
It's very useful when you're giving developers jinja, you can do some very awesome stuff with just jinja & dbt without having to use Python. |
Allowing set statements like jinja would help clean up some of the templates I have (e.g., conditionally building up a string which is used multiple times later in the template).
with
statements can mostly be used as a workaround, however I've found this can get quite verbose in some cases.The text was updated successfully, but these errors were encountered: