简体   繁体   English

在Ember.js中使用EJS

[英]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. 我想尝试使用JS中的一些新功能,所以我选择做Node和Ember.js,我读到Ember.js与模板引擎无关,所以我想知道它是否支持EJS,因为它受支持按节点,并且与我习惯的ERB非常相似。

Thanks 谢谢

You can use Ember views just like Backbone views if you don't want to use Handlebars. 如果不想使用车把,则可以使用Ember视图,就像使用Backbone视图一样。 However, we did a significant amount of work to make Handlebars templates update automatically when their underlying properties change. 但是,我们做了很多工作来使Handlebars模板的基础属性更改时自动更新。 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. 请记住,如果您使用除把手以外的模板引擎,则不会进行自动更新(这是Ember IMO吸引力的很大一部分)。

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. 话虽如此,您可以将任何视图的template属性设置为返回字符串的函数,并将其呈现到屏幕上。

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/ 如果您想了解更多详细信息,请参阅我在SproutCore博客上写的关于我们为什么选择Handlebars的博客文章: http : //blog.sproutcore.com/why-handlebars/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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