Sails JS与EJS,但链接器编译handlebars公共模板 [英] Sails JS with EJS but linker to compile handlebars public templates
问题描述
我一直在寻找一个很好的组合,端到端(MVC)框架与Node结合使用,目前我决定使用SailsJS / EmberJS做一个可以玩的样板,也可以用于未来的项目。
SailsJs(开箱即用的应用程序)使用EJS来编译后端视图。
EmberJs(默认情况下,入门工具包)使用句柄来编译前端视图。
我想保持模板语言(EJS)关于SailsJS的链接器的一个例外。它目前将公共模板编译为与工具不兼容的jst.js。我想改变这个,所以'jst.js'将包含句柄编译的模板,因此他们可以将它们提供给前端(ember应用程序)都可以使用。
我假设为此需要一个附加的节点库。为了使链接器将编译的模板输出到公共目录,我将如何配置Gruntfile.js来使用该库?
当前版本的grunt-ember-templates不知何故, dev:
部分无效。
一旦我把它剥离出来就可以立即工作:
var pipeline = require('../ pipeline') ;
module.exports = function(grunt){
grunt.config.set('emberTemplates',{
compile:{
options:{
amd:true,
templateBasePath:pipeline.templateBasePath
},
文件:{
'.tmp / public / jst.js':pipeline.templateFilesToInject
}
}
});
grunt.loadNpmTasks('grunt-ember-templates');
};
I'm a bit new to Node and javascript backend frameworks so please bear with me:
I've been searching around to find a nice combination of front-end, back-end (MVC)frameworks to work with Node, and I've currently decided upon using SailsJS/EmberJS to make a boilerplate which I can play around with and maybe use for future projects.
SailsJs (out of the box generated app) uses EJS to compile back-end views. EmberJs (by default, starter kit) uses handlebars to compile front-end views.
I want to keep the templating language (EJS) as it is with one exception regarding SailsJS' linker. It currently compiles public templates as 'jst.js' which are not compatible with handlebars. I would like to change this so 'jst.js' will contain handlebars compiled templates therefore they get served to the front-end (ember app) all ready to use.
I assume that an additional node library would be required for this. How would I go about configuring Gruntfile.js to use that library in order for the linker to output handlebars compiled templates to the public directory ?
With the current version of grunt-ember-templates somehow the dev:
section did not work.
Once I stripped it out it worked right away:
var pipeline = require('../pipeline');
module.exports = function(grunt) {
grunt.config.set('emberTemplates', {
compile: {
options: {
amd: true,
templateBasePath: pipeline.templateBasePath
},
files: {
'.tmp/public/jst.js': pipeline.templateFilesToInject
}
}
});
grunt.loadNpmTasks('grunt-ember-templates');
};
这篇关于Sails JS与EJS,但链接器编译handlebars公共模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!