Hello,
I just started using Nunjucks in a project and am really enjoying it! I have one question, which I assume will be obvious to some, that I can't seem to figure out.
Assume the following scenario:
===== Javascript object:
someObj = {
items: [1,2,3,4,5]
}
===== Template (someFile.html):
{% for item in items %}
{{item}}
{% endfor %}
===== Initial render call
nunjucks.render('someFile.html', someObj, function(err, res) {
$("body").html(res);
});
This will render the page printing the following to the body of the HTML page:
Here's my question: If I want to update the rendered template with new data, is there anyway to accomplish that?
For example, if I were to open the Javascript console and update someObj's items key like so:
someObj.items = [6,7,8,9]
How can I get the template to reflect the object's updated value? Is there a method I can call? Do I need to re-render the template?
I really appreciate any help I can get. Thank you.
JP