How to swap Handlebars for EJS


#1

Hello everyone,

I̶’̶m̶ ̶w̶o̶n̶d̶e̶r̶i̶n̶g̶ ̶h̶o̶w̶ ̶d̶o̶e̶s̶ ̶o̶n̶e̶ ̶s̶w̶i̶t̶c̶h̶ ̶E̶m̶b̶e̶r̶ ̶f̶r̶o̶m̶ ̶H̶a̶n̶d̶l̶e̶b̶a̶r̶s̶ ̶t̶o̶ ̶E̶J̶S̶?̶ ̶I̶’̶d̶ ̶l̶i̶k̶e̶ ̶t̶o̶ ̶t̶a̶k̶e̶ ̶o̶u̶r̶ ̶e̶x̶i̶s̶t̶i̶n̶g̶ ̶A̶P̶I̶ ̶d̶o̶c̶u̶m̶e̶n̶t̶a̶t̶i̶o̶n̶ ̶w̶e̶b̶s̶i̶t̶e̶ ̶w̶h̶i̶c̶h̶ ̶u̶s̶e̶s̶ ̶(̶h̶t̶t̶p̶s̶:̶/̶/̶g̶i̶t̶h̶u̶b̶.̶c̶o̶m̶/̶a̶k̶s̶a̶l̶j̶/̶k̶e̶e̶n̶D̶o̶c̶ ̶w̶h̶i̶c̶h̶ ̶i̶s̶ ̶E̶J̶S̶)̶ ̶a̶n̶d̶ ̶d̶r̶o̶p̶ ̶i̶t̶ ̶i̶n̶t̶o̶ ̶n̶e̶w̶ ̶e̶m̶b̶e̶r̶-̶c̶l̶i̶ ̶g̶e̶n̶e̶r̶a̶t̶e̶d̶ ̶p̶r̶o̶j̶e̶c̶t̶.̶ ̶T̶h̶e̶ ̶w̶h̶o̶l̶e̶ ̶t̶h̶i̶n̶g̶ ̶i̶s̶ ̶a̶l̶r̶e̶a̶d̶y̶ ̶d̶o̶n̶e̶ ̶a̶n̶d̶ ̶l̶o̶o̶k̶s̶ ̶b̶e̶a̶u̶t̶i̶f̶u̶l̶ ̶p̶l̶u̶s̶ ̶f̶e̶e̶d̶s̶ ̶f̶r̶o̶m̶ ̶m̶a̶r̶k̶d̶o̶w̶n̶ ̶f̶i̶l̶e̶s̶ ̶s̶o̶ ̶r̶e̶w̶r̶i̶t̶e̶ ̶i̶s̶ ̶n̶o̶t̶ ̶o̶p̶t̶i̶m̶a̶l̶ ̶n̶o̶r̶ ̶w̶a̶n̶t̶e̶d̶.̶ ̶I̶ ̶s̶i̶m̶p̶l̶y̶ ̶w̶a̶n̶t̶ ̶t̶o̶ ̶u̶s̶e̶ ̶d̶i̶f̶f̶e̶r̶e̶n̶t̶ ̶t̶e̶m̶p̶l̶e̶t̶i̶n̶g̶ ̶e̶n̶g̶i̶n̶e̶,̶ ̶i̶n̶ ̶t̶h̶i̶s̶ ̶c̶a̶s̶e̶ ̶E̶J̶S̶.̶ ̶H̶o̶w̶ ̶d̶o̶e̶s̶ ̶o̶n̶e̶ ̶g̶o̶ ̶a̶b̶o̶u̶t̶ ̶g̶e̶t̶t̶i̶n̶g̶ ̶e̶m̶b̶e̶r̶ ̶t̶o̶ ̶u̶s̶e̶ ̶E̶J̶S̶ ̶i̶n̶s̶t̶e̶a̶d̶ ̶o̶f̶ ̶h̶a̶n̶d̶l̶e̶b̶a̶r̶s̶.̶

I’m in the process of porting a api documentation project that uses EJS to ember which requires handlebars. The basic MVP is Ember-API-Docs here but it currently uses node which wraps ember as to allow ejs rendering utilizing express. The primary objective is to make it wholy Ember project so any suggestions or assistance is greatly appreciated. Thank you!


#2

I am not sure what EJS is but if it is this it seems like an abandoned project. So it will be a roll your own project. It would be much faster to switch to Handlebars I think.


#3

@broerse I suspect it’s this or this. Basically a different template layer.

@Bartekus, I’m not sure but based on an ember addon search I’m doubtful that anyone else has done this. However, emblem.js might fall into this category so you could start there to see how they integrated with ember.


#4

@Panman8201 The first one is the same one I found. Last commit in 2009. The second one is a much better maintained choice. Still seems like a lot of work to do this.


#5

Ah, didn’t go so far as to check repo’s. Just seen that you linked to a Google Code site…

Agreed, doing this integration would be no easy task, especially to maintain as ember evolves.


#6

Well since I needed to get this done fast I was left with no choice but to utilize the skill-set that I posses, mainly node and it’s extensive tooling (I prefer webpack, but in this case gulp was a faster route). So in an essence I wrapped ember in a node/express server and simplified all the ingredients to their basics as to make it as simple to grok as possible.

Since sharing is caring, here is the open-source version of the project: Ember-API-Docs

I would definitely like to convert this into a full fledged Ember app so at this point I would love any and all pointers as to how best go about doing it. Also pull requests are always welcomed and greatly appreciated!

Cheers


#7

I simply want to use different templeting engine, in this case EJS.

This is a case of your assumptions being unhelpful. It really is not simple to use a different templating engine in ember. You can’t just switch it out. There is nothing in existence that can replace handlebars. If you use ember, you have to use handlebars because the alternative would be to write a massive project that does all the stuff htmlbars does in ember.

So what about emblem.js? That compiles to handlebars. So if you can compile your existing code to handlebars then you can do that. But you can’t just switch out handlebars from ember.


#8

Indeed, we’ve already established that so if you we’re to look at the post above yours, you’d see that I’m looking at reimplementing what is done in ejs now in handlebars. Any specific help is much appreciate but I’m not looking at discussing semantics here. The MVP project is setup and working in such way at to stream line the transition from ejs to handlebars, offering anybody skilled in the later but not the former ability to see what is and thus understand what needs to be.

Bottom line here is that the way everything looks and works now has to be transitioned to ember - aka making it wholly ember centric project.