0

サーバーの起動時に、ネストされたテンプレートフォルダーをスキャンしてコンパイルする必要があります。そのために私はember-skeletonを使用しています。Assetfileの次のルーチンは、ハンドルバーファイルがすべてテンプレートフォルダーにある限り、ハンドルバーファイルをスキャンしてコンパイルする作業に適しています。

  match 'templates/**/*.handlebars' do
    filter HandlebarsFilter
    filter TemplateFilter,
    #filter LoaderFilter,
      :module_id_generator => proc { |input|
        #input.path.sub(/^templates\//, "#{APPNAME}/~templates/").sub(/\.handlebars$/, '')
        input.path.sub(/^templates\//, "").sub(/\.handlebars$/, '')
      }
    if ENV['RAKEP_MODE'] == 'production'
      uglify {|input| input}
    end
    concat 'app.js'
  end

私のファイルリストはayによって大きくなり、ファイルを次のようなフォルダに分類したいと思います。

templates/products/
templates/products/index.handlebars
templates/products/new.handlebars                  
templates/products/edit.handlebars                  

templates/files/
templates/files/index.handlebars
templates/files/new.handlebars
templates/files/edit.handlebars                  

上記のコードを変更して、ハンドルバーファイルを1レベル深くスキャンし、エントリに対してフィルターを実行できるようにします。これは、RubyやRailsに精通している人にとっては非常に簡単なはずです。

私は運が悪かったので、次のことを試しました。また、誰でもそのようなルーチンをデバッグする方法を教えてくれますprint input。ルーチン内で実行しようとしましたが、サーバーがクラッシュしました:)

  match 'templates/**/**/*.handlebars' do
4

1 に答える 1

0

ネストmatch 'templates/**/*.handlebars' doされたフォルダのスキャンはすでに処理されており、変更する必要はありません。テンプレート名に階層を反映するだけです。

templateName: "product/index"
于 2013-01-24T15:18:32.827 に答える