0

私はMetalsmith WebサイトにUnderscoreのテンプレートエンジンを使用していますが、私はfooter部分にアクセスするのに少し問題があります。Metalsmithでアンダースコアの部分文字列を使用するには?

ReferenceError: footer is not defined 

私はどのように呼びますか?私は間違って何をしていますか?

ありがとうございます。

posts/ 
src/ 
templates/ 
- base.tpl.html 
- partials/ 
-- footer.tpl.html 

ここでポスト例です:

... 
.use(layouts({ 
    engine: 'underscore', 
    directory: 'templates', 
    partials: 'templates/partials' 
})) 

はここに私のフォルダ構造です:

--- 
title: My First Post 
date: 2012-08-20 
layout: base.tpl.html 
--- 

# This is my title 

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sed magna vel eros malesuada fringilla. 

そして、ここに私のhtmlページです。ここ

は私の鍛冶のビルドファイルのテンプレート一部です:

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <title><%- sitename %></title> 
    </head> 
    <body> 
    <h1>Hello, world!</h1> 

    <%= contents %> 

    <% footer %> <---- THIS IS UNDEFINED 
    </body> 
</html> 

答えて

0

私はあなたがあなたのビルドファイル内のオプションpartialExtension使用する必要があると思います:プラグインが<% footer %>を処理するとき、それは本当にただfooterの代わりに、という名前のファイルを検索するため...

... 
.use(layouts({ 
    engine: 'underscore', 
    directory: 'templates', 
    partials: 'templates/partials', 
    partialExtension: '.tpl.html' 
})) 

https://www.npmjs.com/package/metalsmith-layouts#partialextension

footer.tpl.html

(試験されていない)

関連する問題