How to escape dynamic variable

Hi there! I am using templates for my page generation.

For example, i have one query as:

{{query (and (todo now later) <% current page %> ) }}

But instead of allowing template generation to substitute the variable, I would like to keep it intact - query would work the same way either way and we would avoid hard coding the page name.

I would need to escape once, so after page generation it would land as correct statement.

Is it possible? If not, I will create FR. Thanks!

I think it is a bug. Click on the block and then press ESC. The value should show. I believe that it worked before.

@danzu, so you mean, that in the past, dynamic variable inside queries wasn’t substituted when generating from template?

It was not generating at some point. I just tested and it is working at the moment. Also, I think I may have misunderstood your question at first.
On a page, when you have {{query (and (todo now later) <% current page %> ) }}, the dynamic variable will remain. However, with a template the variable will be substituted. Because the idea here is that, the template would substitute as much to give you a desired output by evaluating variables. In short, your ask is to turn off the substitution of the variable, which I do not think is possible. Feet free to open a feature request

It’s because having a dynamic variable as is in non substituted form has a value on a target page :slight_smile:

Usually in any templating language you have an ability to escape the special characters so they are realized in original form.

So instead <% current page %> you could write <<% current page %>> and in generated page we would get a query using dynamic variable in proper form, not hard coded value.

Oh my, it’s actually the same pattern as in Jinja2. I hope that is principle, not accident :stuck_out_tongue:

{{query (and (todo now later) <% <% %> current page <% %> %> ) }}

That query used in template should generate a proper query on target page.

1 Like