How Jinja works with referencing in hyperquery
Hyperquery fully supports both Jinja and {
-based templating (read more about our referencing capabilities in Making your first app if you haven't already).
While they integrate seamlessly, one important thing to note is that variables defined through our app-building blocks (and reference-able through the {
syntax) exist in a different namespace than Jinja variables (created through {% set .. %}
. We render queries according to the following preference stack:
- First, we string replace any
{
-based (app-building control block) references. - Second, we then render Jinja.
This has a number of advantages:
- We can handle (i.e. avoid) collisions between app-building blocks and Jinja variables much more elegantly.
- Because of the above, it is substantially more intuitive for the end-user to know what variables are defined where.
- We are able to handle refactoring (i.e. renaming of app-building components) much more elegantly - this comes out of the box!
Updated over 2 years ago