You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{% setmyVariable="Variable value" %}
myVariable value is: {{ myVariable }}
What I need is to get myVariable from template before compiling it.
In other words, something like:
varnunjucks=require('nunjucks');varenv=nunjucks.configure('templates/');vartmpl=env.getTemplate('index.nj')// Now I need to get value of variable `myVariable` from template, like `tmpl.getVariables();`// to process it afterward...compilationstuff ...
Thanks in advance for any help
The text was updated successfully, but these errors were encountered:
This goes against MVC - the view consumes the model, not the other way around.
Your templates should consume data provided to them from the controllers. If you need to go the other way, you are doing it wrong.
Hi
Sorry for quite newbie question.
Is there a way to get variables from template?
For example, I have
index.nj
templateWhat I need is to get
myVariable
from template before compiling it.In other words, something like:
Thanks in advance for any help
The text was updated successfully, but these errors were encountered: