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
Some custom template code that would be entered in and could change depending on how someone wants to use it, but still references parent elements (Name).
<script>
$(function() {
var source = $('#entry-template').html();
var template = Handlebars.compile(source);
var html = template(jsonData);
$('body').append(html);
var source2 = $('#inject').html();
var template2 = Handlebars.compile(source2);
Handlebars.registerPartial('inject', template2);
</script>
In this example the ../Name is not found in the inject template. I need a way to be able to insert a partial template into a reusable template and still get values higher in the tree. The injectable template would be user defined so I don't know what elements they may need, but they need access to everything.
The text was updated successfully, but these errors were encountered:
We've chosen to not support ../ syntax for partials as it can lead to a number of confusing behaviors. The 2.0 code line allows you to pass in arbitrary parameters to your partial, so you can provide access to the data that you need, i.e. {{> foo parentName=name}}.
I understand the reason behind not supporting the ../ syntax. Is there or can there be a way to add additional external template code before it compiles?
This request is to either make Partials aware of parent items or to give the ability to inject templates into other templates.
Imagine a data structure like:
And some reusable template code for the data structure:
Some custom template code that would be entered in and could change depending on how someone wants to use it, but still references parent elements (Name).
Script to compile:
In this example the
../Name
is not found in theinject
template. I need a way to be able to insert a partial template into a reusable template and still get values higher in the tree. The injectable template would be user defined so I don't know what elements they may need, but they need access to everything.The text was updated successfully, but these errors were encountered: