Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More generic approach to templating systems #4

Closed
andrzejpolis opened this issue Jun 29, 2012 · 2 comments
Closed

More generic approach to templating systems #4

andrzejpolis opened this issue Jun 29, 2012 · 2 comments

Comments

@andrzejpolis
Copy link

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.

@millermedeiros
Copy link
Owner

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.

Thanks for the feedback.

@millermedeiros
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants