2014-07-16 2 views
1

으로 내가 모든 핸들 템플릿을 렌더링 할GruntJS 소스

[ { src: 
    [ './src/branding/appLogo/template.hbs', 
    './src/buttons/append/template.hbs', 
    './src/buttons/button/template.hbs', 
    './src/buttons/clean/template.hbs', 
    './src/buttons/clear/template.hbs', 
    './src/buttons/danger/template.hbs', 
    './src/buttons/default/template.hbs', 
    './src/buttons/disabled/template.hbs', 
    './src/buttons/large/template.hbs', 
    './src/buttons/link/template.hbs', 
    './src/buttons/primary/template.hbs', 
    './src/buttons/small/template.hbs', 
    './src/buttons/success/template.hbs', 
    './src/documentation/technology-overview/template.hbs', 
    './src/forms/checkbox/template.hbs', 
    './src/forms/fieldAppend/template.hbs', 
    './src/forms/fieldDefault/template.hbs', 
    './src/forms/fieldError/template.hbs', 
    './src/forms/fieldPrepend/template.hbs', 
    './src/forms/fieldPrependAppend/template.hbs', 
    './src/forms/radioButton/template.hbs', 
    './src/forms/select/template.hbs', 
    './src/forms/textarea/template.hbs', 
    './src/icons/appSwitch/template.hbs', 
    './src/modules/alerts/template.hbs', 
    './src/modules/attributions/template.hbs', 
    './src/modules/avatar/template.hbs', 
    './src/modules/beacon/template.hbs', 
    './src/modules/d3DonutChart/template.hbs', 
    './src/navigation/appSwitcher/template.hbs', 
    './src/navigation/avatarDropdown/template.hbs', 
    './src/navigation/contextMenu/template.hbs', 
    './src/navigation/headerMenu/template.hbs', 
    './src/navigation/paginate/template.hbs', 
    './src/prototypes/home/template.hbs', 
    './src/structures/form/template.hbs', 
    './src/structures/header/template.hbs', 
    './src/typography/blockquote/template.hbs', 
    './src/typography/floats/template.hbs', 
    './src/typography/headers/template.hbs', 
    './src/typography/hidden/template.hbs', 
    './src/typography/hr/template.hbs', 
    './src/typography/hrText/template.hbs', 
    './src/typography/lists/template.hbs', 
    './src/typography/paragraph/template.hbs', 
    './src/typography/pre/template.hbs', 
    './src/typography/table/template.hbs', 
    './src/typography/tags/template.hbs', 
    './src/utilities/extends/template.hbs', 
    './src/utilities/keyframes/template.hbs', 
    './src/utilities/mixins/template.hbs', 
    './src/utilities/svgFilterPieShrink/template.hbs', 
    './src/utilities/svgFilterSubtleDropShadow/template.hbs' ], 
    dest: './build/scripts/handlebars.js' } ] 

같은 거대한 배열을 가지고 있고 그들은 모두 하나의 파일에 끝나야한다 glob에.

module.exports = (grunt) -> 
    config = grunt.file.readJSON("config.json") 
    hbsGlob = '' 
    grunt.task.loadTasks('./tasks') 
    grunt.option('config', config) 

    grunt.initConfig 
    pkg: grunt.file.readJSON("package.json") 

    handlebars: 
     options: 
     namespace: 'Guide' 
     processName: (path) -> 
      return path.replace('.js', '').replace('/', '.') + '.template' 

     guide: 
     files: 
      @hbsGlob 


    grunt.registerTask 'etch-scripts', => 
    glob = grunt.option('filteredGlob') 
    glob.push "!./src/**/*.{md,js,json}" 

    options = 
     rename: (dest, matchedSrcPath, options) -> 
     return dest 

    @hbsGlob = grunt.file.expandMapping(glob, config.build + '/scripts/handlebars.js', options) 

    grunt.task.run 'handlebars:guide' 

    grunt.loadNpmTasks('grunt-contrib-handlebars'); 

내가 얻고 유일한 출력

Running "handlebars:guide" (handlebars) task 
>> 0 files created. 

Done, without errors. 

그래서 나는, 소스/타겟으로하는 글로브를 사용할 수 있습니다 잘못된 것입니다 어떤 생각인가?

답변

0

이 문제에 대한 많은 연구 끝에 완벽하게 작동하는 약간의 대안을 찾았습니다. 가이드 작업은 내가

guide: 
    files: '<%= hbsGlob %>' 

로 설정 그리고 모든 것이 완벽하게 밖으로 내장 :

는 hbsGlob 변수를 설정 한 후, 나는 그런트 설정 핸들에서 그런 grunt.config.set('hbsGlob', @hbsGlob)

에 var에 있음을 추가!

편집 - 출처 : https://stackoverflow.com/a/14780870/399742

관련 문제