如何制作grub手表子文件夹的手柄模板(Emboy.js应用程序与Yeoman) [英] How to make grunt watch subfolder for handlebars templates (ember.js app with Yeoman)
问题描述
yeoman配置设置为: p>
watch:{
ember_templates:{
files:'<%= yeoman.app%>模板/ ** / *。hbs',
任务:['ember_templates','livereload']
},
- 当模板位于文件夹根目录中时,它的工作原理
- 当模板位于子文件夹
template / mySubfolder
模板没有渲染(没有html被返回) - 当模板丢失时,ember发出错误
所以当模板在子文件夹中时,它被稍微检测到...但为什么不呈现
我试过各种表达式是 Gruntfile.js
,但没有改善。
code> watch:{
ember_templates:{
files:'<%= yeoman.app% > / templates / {,* /} *。hbs',
tasks:['ember_templates','livereload']
},
@Mishik(评论太久)
整个手表部分:
watch:{
ember_templates:{
files:'< %= yeoman.app%> / templates / ** / *。hbs',
任务:['ember_templates','livereload']
},
咖啡:{
文件:['<%= yeoman.app%> / scripts / {,* /} *。coffee'],
任务:['coffee:dist']
},
coffeeTest:{
文件:['test / spec / {,* /} *。coffee'],
任务:['coffee:test']
},
罗盘:{
文件:['<%= yeoman.app%> / styles / {,* /} *。{scss,sass}'],
任务:服务器']
},
中性:{
文件:['<%= yeoman.a pp%> / scripts / {,* /} *。js'],
任务:['neuter','livereload']
},
livereload:{
文件:[
'<%= yeoman.app%> / *。html',
'{.tmp,<%= yeoman.app%>} / styles / {,* /}*.css',
'<%= yeoman.app%> / images / {,* /} *。{png,jpg,jpeg,gif,webp,svg}'
],
任务:['livereload']
}
}
和我没有看到第一次的东西:
ember_templates:{
options:{
templateName :function(sourceFile){
var templatePath = yeomanConfig.app +'/ templates /';
return sourceFile.replace(templatePath,'');
}
},
dist:{
文件:{
'.tmp / scripts / compiled-templates.js':'<%= yeoman.app %> / templates / {,* /} *。hbs'
}
}
}
这是我应该修改的部分吗?
如mishik所述, templates / ** / *。hbs
是完全有效的。如果我们在谈论Yeoman,请注意,您需要在2个地方更改价值:
- 在手表任务内(这是什么你已经尝试过了)
- 进一步下面的把手任务。
问题。
When you create an ember app with Yeoman, it create a handlebars templates folder for you (.hbs).
The yeoman config is set that way :
watch: {
ember_templates: {
files: '<%= yeoman.app %>/templates/**/*.hbs',
tasks: ['ember_templates', 'livereload']
},
- When a template is in the folder root, it works
- When a template is in a subfolder
template/mySubfolder
the template is not rendered (no html is returned) - When a template is missing, ember throw an error
So when the template is in a subfolder, it is somewhat detected... but why not rendered
I tried various expressions is the Gruntfile.js
but it did not improve it.
watch: {
ember_templates: {
files: '<%= yeoman.app %>/templates/{,*/}*.hbs',
tasks: ['ember_templates', 'livereload']
},
@Mishik (too long for a comment)
The whole "watch" part :
watch: {
ember_templates: {
files: '<%= yeoman.app %>/templates/**/*.hbs',
tasks: ['ember_templates', 'livereload']
},
coffee: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
tasks: ['coffee:dist']
},
coffeeTest: {
files: ['test/spec/{,*/}*.coffee'],
tasks: ['coffee:test']
},
compass: {
files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server']
},
neuter: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['neuter', 'livereload']
},
livereload: {
files: [
'<%= yeoman.app %>/*.html',
'{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
],
tasks: ['livereload']
}
}
And something I did not see first time :
ember_templates: {
options: {
templateName: function (sourceFile) {
var templatePath = yeomanConfig.app + '/templates/';
return sourceFile.replace(templatePath, '');
}
},
dist: {
files: {
'.tmp/scripts/compiled-templates.js': '<%= yeoman.app %>/templates/{,*/}*.hbs'
}
}
}
Is it the part I should modify ? I tried a few things, it did not work out.
As noted by mishik, templates/**/*.hbs
is perfectly valid. If we are talking about Yeoman please note that you will need to change the value in 2 places:
- Inside the watch task (which is what you already have tried)
- Further below inside the handlebars task.
This should solve your problem.
这篇关于如何制作grub手表子文件夹的手柄模板(Emboy.js应用程序与Yeoman)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!