简体   繁体   中英

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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM