Open cgarciae opened 9 years ago
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.
Here's a quick example:
PartialResolver templateResolver(List<Template> templates) {
var map = new Map.fromIterables(templates.map((t) => t.name), templates);
return (String name) => map[name];
}
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