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
Hello.
I was looking for some requirejs loaders for templates and come upon your project. It's code looks very clean till now so I could analyze how it works. What comes to my head is that there is no need to stick to one templates compiler.
So here is some idea maybe you'll consider if planning any further development:
Create code to support any template compilation library by using configurable callbacks. As product of this callback return always rendering function html (in case of hogan it means render function of object created by compile, in case of Handlebars it's directly product of template compilation). For some major templating systems (mustache, handlebars, microtemplates) premade callbacks would be nice and some simple configuration (resource extension recognition by convention)?
One nicely written plugin could replace all this plugins created till now that mostly repeat code.
The text was updated successfully, but these errors were encountered:
That is doable, but the user would need to download 2 plugins instead of one to
use it - a generic text transformer plugin and an adapter for the actual
template language - I feel the amount of code reuse wouldn't payoff the
increase in complexity, since every plugin will require a different output
structure and also need to support different options, see #2 and #1.
If it's just a single file and we "inject" the compile methods with a config ( compileAsText(data, options), compile(data, options), parseName(name, options) )
we could only have a single template engine in the whole app (which
is fine in most cases but may not be in all).
I will think more about it and try to at least make it in a way that other devs
can easily tweak/copy the code to implement their own. The main reason why I
created that many plugins was to teach people how to do it and that it could be
used for many different things.
PS: The Handlebars plugin has some advanced features (l10n, autoload helpers)
so the compilation isn't as simple and couldn't fit the same abstraction.
closing this issue since I don't think it will be possible to make a generic approach without drastic changes to the structure and the amount of code reused would be minimal. Thanks for the feedback.
Hello.
I was looking for some requirejs loaders for templates and come upon your project. It's code looks very clean till now so I could analyze how it works. What comes to my head is that there is no need to stick to one templates compiler.
So here is some idea maybe you'll consider if planning any further development:
Create code to support any template compilation library by using configurable callbacks. As product of this callback return always rendering function html (in case of hogan it means render function of object created by compile, in case of Handlebars it's directly product of template compilation). For some major templating systems (mustache, handlebars, microtemplates) premade callbacks would be nice and some simple configuration (resource extension recognition by convention)?
One nicely written plugin could replace all this plugins created till now that mostly repeat code.
The text was updated successfully, but these errors were encountered: