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

[Proposal] Switching default template engine #3407

Closed
RomainLanz opened this issue Dec 1, 2015 · 34 comments
Closed

[Proposal] Switching default template engine #3407

RomainLanz opened this issue Dec 1, 2015 · 34 comments
Labels

Comments

@RomainLanz
Copy link

Dear everyone,

EJS is pretty old, not really fast and has a rubbish syntax.

Also, Sails depends on ejs-locals that is not maintained anymore.

This library is unmaintained, sorry.

What do you think of switching to another templating engine by default?
The developper of ejs-locals recommend to use DustJS or ECT.

Node.JS template engines benchmark

As you can see with this (old) benchmark, ECT and DustJS is two time faster than EJS.

It is also an opportunities to develop some great helpers/filters for Sails like the route helper proposed here: [Proposal] Route helper for view

@RomainLanz RomainLanz changed the title [Proposals] Switching default template engine [Proposal] Switching default template engine Dec 1, 2015
@niallobrien
Copy link

Personally I'd vote for Jade or Nunjucks.

@RomainLanz
Copy link
Author

The syntax of Jade is too different from the default syntax to be the default choice of Sails in my opinion.

Nunjucks seems a great choice. Easy to learn, to read and custom tags seems easy to implement.

@niallobrien
Copy link

Agreed with regards to Jade, but Jade is the default template engine of Express which is why I recommend it. Nunjucks does have a really nice syntax indeed.

@randallmeeker
Copy link

Agree with this statement, also supporting Jade.

Agreed with regards to Jade, but Jade is the default template engine of Express which is why I recommend it.

Or at the least Sails should prompt you for a supported templating engine when generating a new app and not provide a default.

@RomainLanz
Copy link
Author

Jade is the default template engine of Express which is why I recommend it.

Yes it is, but does that mean that every framework using express need to use Jade? No.
Jade is slower than a lot of other simple templating engine, because he need to generate a lot of HTML.

Or at the least Sails should prompt you for a supported templating engine when generating a new app and not provide a default.
It's better if a framework has a default templating engine. With that, devs can create custom helpers/filters and the communities can also use it in packages.

Note: You can specify which templating engine you want sails new sails-jade --template=jade.

@niallobrien
Copy link

Sails already supports Jade with asset linking, it should be pretty straightforward to make it the default. Less work at the end of the day.

@randallmeeker
Copy link

It does not mean EVERY framework using express need to use Jade, it is just a strong argument for it. As far as speed is concerned, it is the slowest JS templating, I'll grant you that. But Jade 2.0 will change that.

It's better if a framework has a default templating engine. With that, devs can create custom helpers/filters and the communities can also use it in packages.

I think I agree, but sails is also advertising itself as being un-opinionated about these things. Which is why I say it might lose the default and ask.

I think at the end of the day it is whatever the Balderdashy team uses in-house will be the default.

@dsazup
Copy link

dsazup commented Dec 2, 2015

I've been using swig for a couple of weeks now, works great. Not sure how is that different from nunjucks but it also looks great. In my opinion jade's syntax is just too ugly for a framework like sails.

@niallobrien
Copy link

@Mirago Swig is no longer maintained as far as I know. Nunjucks would be a better options in my opinion.

@niallobrien
Copy link

For anyone interested, http://adonisjs.com uses Nunjucks - syntax looks great.

@randallmeeker
Copy link

In my opinion jade's syntax is just too ugly for a framework like sails.

I get the fact that we're talking opinion here, but I can't quite get calling Jade ugly (especially when compared with swig). Jade is one of the few templating language that hardly even requires a style guide. Based on being a tabbed language it is already composed, organized and easy to read. It solves much of the spaghetti mess that HTML creates.

As far as Jade is concerned slowness is a valid complaint, dynamic includes is a valid complaint, but ugly is hardly a valid complaint. Combining HTML and Script will hardly be pretty no matter the implementation.

@RomainLanz
Copy link
Author

Wow, AdonisJS seems to be a Laravel port to NodeJs 👮

@niallobrien
Copy link

Yup, laravel.js :)

@dsazup
Copy link

dsazup commented Dec 2, 2015

Hi @randallmeeker, it's completely just my opinion, nothing more. I love swig/nunjucks syntax, therefore I would prefer if one of them was implemented as a default template engine. As I understand you prefer jade, and that is absolutely fine.

@niallobrien
Copy link

To be honest, I don't think Sails.js is going to get many new features. Work has already begun on Trails which will replace Sails.

@RomainLanz
Copy link
Author

@niallobrien That's why this project seems dead?

Why do not continue to work on SailsJS? They can just bump up the major version...

@dsazup
Copy link

dsazup commented Dec 2, 2015

@niallobrien is this true? Is there any more info about it?

@niallobrien
Copy link

@dsazup
Copy link

dsazup commented Dec 2, 2015

@niallobrien thanks. This is a huge surprise to me, especially when we are ~3 weeks into development using sails :/

@niallobrien
Copy link

@Mirago Yeah, but at least there will be a migration path. Are you guys building a SPA app with REST API or a hybrid of server & client code?

@tjwebb
Copy link
Contributor

tjwebb commented Dec 3, 2015

@Mirago As long as you're using Sails 0.11.x or newer, there will be a migration path.

@niallobrien
Copy link

Apologies @tjwebb if I've left the cat out of the hat. :)

@tjwebb
Copy link
Contributor

tjwebb commented Dec 3, 2015

@niallobrien haha, no worries. It is open source, after all: https://github.com/trailsjs 😺 . We have no secrets.

I don't want to derail this thread too much, though, except to say that the conversations in these Sails issues are things that we think about in our design for trails.

@niallobrien
Copy link

@tjwebb Agreed.

I think most here would agree that although Jade is the default template engine for Express (I personally use it daily and like it), and Sails.js already supports Jade (with linking), Nunjucks simply has a much nicer syntax without forcing beginners to wrestle with a whitespace sensitive templating language.

For those reasons I would recommend that Nunjucks should replace EJS as the default templating language for new Sails.js projects. This would also require asset linking functionality out of the box.

@ytzvan
Copy link

ytzvan commented Dec 10, 2015

Why not use Handlebars? It has a clean syntax, powerful filters and the partial support it's pretty good.

@tjwebb
Copy link
Contributor

tjwebb commented Dec 16, 2015

Why not use Handlebars?

Yea, everyone has their pet templating engine that they think is better. That's why the correct approach is to just configure the one you want and not have the framework set one for you.

@kokujin
Copy link
Contributor

kokujin commented Dec 19, 2015

+1 nunjucks

@akd3vs
Copy link

akd3vs commented Dec 19, 2015

I agree with leaving the default as switching is easy, but I'll also like to vote for nunjucks if a change is going to happen.

@niallobrien
Copy link

What can we do to make this happen? Just get a PR together or do we need the core team to agree before wasting time?

@mikermcneil
Copy link
Member

We'll be sticking with EJS.

@niallobrien
Copy link

@mikermcneil Why? Clearly people would like to see Sails move to a templating language that's relevant in today's market, is supported (Bitovi have archived EJS from what I can see) and have it be the default with Sails out of the box. Yes, changing templating languages is easy, but if if the first thing the majority do is change the templating language, then that's surely an indication of friction?

@RWOverdijk
Copy link
Contributor

@niallobrien Sails isn't married to ejs. If you don't like it, use something else? I don't use server-side templating at all, because that's not "relevant to today's market".

@mikermcneil
Copy link
Member

@niallobrien It's not just because I'm a big fuddy duddy and it's what we use in all our projects (but that is also true)-- it's just that I believe it's the most practical approach. This is actually one of the things I covered in one of my very first talks about Sails, and one of the things from that talk that is still most relevant today. The reason why I made this choice early on is that EJS looks like ERB, which looks like PHP, which looks like GSP, which looks like JSP, which looks like ASP. It allowed me to much more quickly onboard developers who were new to Node. We all know there's nothing magical going on with Jade et al -- but it can be a big shock if you're not used to seeing it. With EJS, I could show Sails views to people with little to no technical experience, and they'd be able to edit them to match customer copy or comps using skills they learned from messing with Geocities templates in the early 2000s, or later Wordpress themes. Hope that helps :)

Going forward, I'd love it if everyone who is passionate about this issue would help improve the docs to make it more straightforward to switch to other templating languages.

@mikermcneil
Copy link
Member

To bring some closure to the discussion earlier on in this issue, re:

Work has already begun on Trails which will replace Sails.

@RomainLanz @niallobrien @Mirago @randallmeeker Statements like these have been causing some major confusion in our community. I've posted more about this in the Status of Sails issue, but heres a quick recap:

  • Trails is not affiliated with Sails or our team.
  • Only one person left the Sails.js project to create Trails: Travis Webb; someone who joined the Sails project fairly recently as a contributor in 2015.
  • The core team and I are 100% committed to the continued development and support of Sails and Waterline. We currently use the latest stable release of Sails in production, as do many other companies and developers all over the world.

If you have questions or concerns about the health of the community, the status of the project, the future of the framework, or any other strategic questions about Sails, our team, or our mission, please don't hesitate to contact me directly.

@balderdashy balderdashy locked and limited conversation to collaborators Jan 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests