0

Yeoman で ember アプリを作成すると、ハンドルバー テンプレート フォルダー (.hbs) が作成されます。

Yeoman の設定は次のように設定されています。

watch: {
        ember_templates: {
          files: '<%= yeoman.app %>/templates/**/*.hbs',
          tasks: ['ember_templates', 'livereload']
        },
  • テンプレートがフォルダーのルートにある場合、それは機能します
  • テンプレートがサブフォルダーにある場合、テンプレートはtemplate/mySubfolderレンダリングされません (html は返されません)。
  • テンプレートが見つからない場合、ember はエラーをスローします

したがって、テンプレートがサブフォルダーにある場合は、ある程度検出されます...しかし、レンダリングされないのはなぜですか

いろいろ表現してみましたGruntfile.jsが改善されませんでした。

watch: {
        ember_templates: {
          files: '<%= yeoman.app %>/templates/{,*/}*.hbs',
          tasks: ['ember_templates', 'livereload']
        },

@Mishik (コメントには長すぎます)

「時計」部分全体:

    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']
        }
    }

そして、私が初めて見たものではありません:

    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'
            }
        }
    }

それは私が修正する必要がある部分ですか?私はいくつかのことを試しましたが、うまくいきませんでした。

4

2 に答える 2

0

同じ問題が発生しましたが、置換の問題であり、「/templates/**」が機能しないことがわかりました。

これが私の例です:

       templateName: function (sourceFile) {
                var templatePath = yeomanConfig.app + '/templates/web/';
                    sourceFile= sourceFile.replace(templatePath, '');
                templatePath = yeomanConfig.app + '/templates/mobile/';
                    sourceFile= sourceFile.replace(templatePath, '');
                templatePath = yeomanConfig.app + '/templates/tablet/';
                    sourceFile= sourceFile.replace(templatePath, '');
                return sourceFile;
            }
于 2014-09-02T22:52:04.240 に答える