问题描述
我的 Emberjs 应用程序运行缓慢,所以我想预编译我的模板以稍微简化运行时.但是,我不知道如何继续.我阅读了 http://handlebarsjs.com/precompilation.html 和 Emberjs 介绍,但没有,我所能做的只是创建一个模板按照网站上的说明创建文件,但我无法弄清楚在 Emberjs 中如何处理这个模板文件.
My Emberjs app is running slowly so I wanted to precompile my template to ease the runtime a bit. However I'm lost on how to proceed. I read http://handlebarsjs.com/precompilation.html and Emberjs introduction but no, all I could do was just creating a template file as instructed on the site, and I cannot figure out what and how to do with this template file in Emberjs.
如何在 Emberjs 中预编译模板?模板文件应该怎么做才能在Emberjs中使用?
How can I precompile templates in Emberjs? What should I do with the template file to use it in Emberjs?
推荐答案
您可以将预编译的把手输出设置为 ember 视图上的模板属性(而不是 templateName).这也是 ember 在幕后所做的
You can set the precompiled handlebars output to the template property (not templateName) on you ember view. This is what ember also does under the hood
MyApp.MyView = Ember.View.extend({
templateName: "myViewWhatever",
template: Ember.Handlebars.compile('<p>{{blah}}</p>'),
})
这篇关于Emberjs Handlebars 预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!