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
Given that templates already have names, wouldn't it be easier to resolve partial by template names? You'd have to create the field List<Template> partials. But this example
var partial =newTemplate('{{ foo }}', name:'partial');
var resolver = (String name) {
if (name =='partial-name') { // Name of partial tag.return partial;
}
};
var t =newTemplate('{{> partial-name }}', partialResolver: resolver);
var output = t.renderString({'foo':'bar'});
could be reduced to something like this
var partial =newTemplate('{{ foo }}', name:'partial-name');
var t =newTemplate('{{> partial-name }}', partials: [partial]);
var output = t.renderString({'foo':'bar'});
The text was updated successfully, but these errors were encountered:
I want to make sure that this library can be used with lazily loaded templates. I.e. you may not have already loaded and parsed the list of partials at the time you create a template.
But it should be pretty easy to come up with a utility function to do what you want. Perhaps it would make sense to include something like this in the library.
Can you create a constructor for Template that also accepts a List<Template> partials and does what you proposed? I am creating a plugin for Redstone based on mustache, not having to implement that funtion would better long term.
Given that templates already have names, wouldn't it be easier to resolve partial by template names? You'd have to create the field
List<Template> partials
. But this examplecould be reduced to something like this
The text was updated successfully, but these errors were encountered: