Core: Additional template engine support

Created on 6 Mar 2016  路  9Comments  路  Source: adonisjs/core

Hello everyone,
I don't know if there's a specific reason to choose nunjucks over other template engines, but wouldn't it be nice to give users a chance to choose their favourite template engine?

There're nice alternatives to nunjucks, here you can find the list of most commonly used/followed* ones:

I hope you can at least consider this request. Many others who uses _Express_ or _Koa_ for some time are not familiar with nunjucks unless they didn't integrate it themselves. And this makes things a bit harder than they should for beginners. For example _recursive includes_ and _layouts_ and _partials_ are not that much easy to manage as _pug_ or _handlebars_ in _nunjucks_.

*: number of stars as of 2016-03-06

Most helpful comment

@gokaygurcan Pug was a must-have for me (lots of mixins I use across projects/platforms), so I've written a simple pug provider for adonis https://www.npmjs.com/package/adonis-pug

It should be straight forward to write your own for other engines

All 9 comments

@gokaygurcan Nunjucks has support for almost everything you would ever need and if something is missing, i would love to consider that.

Now couple of reasons why not the option of multiple templating engines

  1. Koa/Express are simple ( nice ) libraries and have very different nature from Adonis, so i will not make any comparisons here.
  2. Adonis is tightly coupled, let's take the example of CSRF protection http://adonisjs.com/docs/2.0/security#csrf-protection. Now Adonis gives you a pre-built helper to access CSRF tokens right from your views without any extra effort. Giving the choice of 100 different template engines will remove this flexibility.

At the end, my goal is not take the functionality away, but to spend my hardwork on build stable solutions, which should save everyone's time. And keeping everything open will add a lot of unnecessary boilerplate and you have configure everything to get started

Thanks for your reply.
I'm not saying that nunjucks doesn't have any of these features. I'm just saying that it's hard to use than the rest of them. If, for instance, CSRF protection is the reason to use nunjucks, I'd rather implement it in a custom way and go with handlebars. It's probably not the whole reason though, so, anyways.

Maybe this is my lack of knowledge but this is really hard to do in nunjucks when compare it with handlebars for example:
https://gist.github.com/gokaygurcan/96d2253058bfafe43319
(it doesn't allow me to create sub-directories, so all - characters are actually /characters)

Again, I don't want to have 100 different options. But it would be nice to have at least one or two more. I just listed the most common ones so maybe people can say their opinion or something. Sticking with one option, which is not that much common and widely used, is not a good thing for this kind of project imho.

Sorry i don't see any point in including multiple templating engines.

Okay, good luck.

@gokaygurcan Pug was a must-have for me (lots of mixins I use across projects/platforms), so I've written a simple pug provider for adonis https://www.npmjs.com/package/adonis-pug

It should be straight forward to write your own for other engines

Hey @webdevian,
Thanks for letting me know. I'm more into Sinatra-like frameworks. That and the authors response made me decide to move away from Adonis.

Nunjucks takes approximately 5 minutes to learn, if you cannot spend this time to use a new framework that not the author's problem. 馃槃

I don't agree but also don't want to make this become a pissing contest. As you said earlier,

Pug was a must-have for me

Handlebars is the same to me. Since the author had no plans for it, I didn't spent my precious time on it.

Yes, I spent some time on Nunjucks, also created a PR to make it supported in express-generator package too. But Adonis is not a long term solution for me. And here we are now.

Thank again for unofficial Pug support. And I believe the keyword is unofficial in this context ;)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seanc picture seanc  路  4Comments

milosdakic picture milosdakic  路  3Comments

dezashibi picture dezashibi  路  4Comments

imperez picture imperez  路  4Comments

krunaldodiya picture krunaldodiya  路  3Comments