Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using EJS with Ember.js

I wanted to try out some of the new stuff in JS, so I chose to do Node and Ember.js I have read that Ember.js is agnostic to the templating engine, so I was wondering whether it supports EJS, since that is supported by node, and is quite similar to ERB, what I am used to.

Thanks

like image 882
nambrot Avatar asked Dec 21 '22 04:12

nambrot


1 Answers

You can use Ember views just like Backbone views if you don't want to use Handlebars. However, we did a significant amount of work to make Handlebars templates update automatically when their underlying properties change. Keep in mind that if you use a template engine other than Handlebars, auto-updating (a big part of the appeal of Ember IMO) will not happen.

That being said, you can set the template property of any view to a function that returns a string, and it will render it to the screen.

var view = Ember.View.create({
  template: function() { return "Hi there!" }
});

view.appendTo('#container');

If you'd like more details, please see the blog post I wrote on the SproutCore blog about why we picked Handlebars: http://blog.sproutcore.com/why-handlebars/

like image 198
Tom Dale Avatar answered Dec 24 '22 02:12

Tom Dale