-
Notifications
You must be signed in to change notification settings - Fork 15
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
Choose template engine #2
Comments
My personal preference would be either Handlebars or Mustache. I think the helpers are really usefull. Twig might be a better pick for Drupal projects, but I'm not sure if the Drupal team uses Twig instead of PHPTemplate. |
In the initial setup I've chosen Handlebars, and seems to work quite well. |
I also created a branch where I implemented a Twig version: This is not ready to be merged, but instead should be used to create a setup where you can switch between the two. As far as I can see both implementations are very compatible, but have slight differences in how to use at a template level (mostly on how to work with context/scope). I had to rewrite most of the twig-loader to get it correctly working with webpack resolving and dynamic templates. I have opened a PR there, and currently the twig branch is linked to my Fork with those changes in place. Having implemented two template engines now, I think it's safe to say that if a template engine has hooks for resolving files, and have a compile and render function for the templates, I am able to create a loader for it. We might also want to look at RazorJS to support .NET sites, but I would have to create a webpack loader for it. The project is 4 years old and not that active, but that could also mean that it has nog bugs or doesn't need new features :P. |
I'm closing this, since most of the setup is fairly tightly coupled with Handlebars (would create a lot of duplication to support other template engines). For converting handlebars to other languages, the muban-convert-hbs package is created. Also, we have a setup in the works that uses the source hbs templates as-is in Twig. |
Goals:
To render and preview components and pages, we don't want to duplicate elements across different HTML pages, so we want a template system that can include partials.
What to look for in a template system:
Open for discussion
Highlighted template engines:
Pug (formerly know as Jade)
We need our templates to be usable, so it must be plain HTML. Pug uses different syntax, so not useful.
Mustache / Handlebars
Easy
{{ }}
syntax. Handlebars adds some extra features (like blocks and helpers) that might be useful. We would probably only use a limited set of features.nunjucks
Nice syntax, looks a bit like twig.
ejs
Oldskool and 'ugly'
twig.js
JS port of twig. Feels experimental, but has good support and usage. Maybe weird to use a JS solution if we're going for twig. Has benefit of easy integration in PHP projects if we choose this.
Pre-render or serve via express?
Are we going to pre-render our templates and view them as HTML files, or are we using express to view them? I guess pre-rendering makes more sense since we need to deliver HTML files anyway?
List of supported template engines by express (if we want to use that to render/preview)
Might want to put the discussion in a separate ticket, this was only added in case it would influence the decision for a specific template engine.
The text was updated successfully, but these errors were encountered: