0
私はヒスイテンプレート(「メインページ」)と再利用可能なテンプレート(「プロダクトテンプレート」)を持っています。 'product template'は動的データを表示する必要があります。他の多くのページで使用されているため、統一されていて変数名に依存できません。ジェイド:ランダム変数をインクルードされたテンプレートに渡すにはどうしたらいいですか?
// main page
... (some code) ...
- var outerObj = [
{ title: '...', price: '...', description: '' },
{ title: '...', price: '...', description: '' },
{ title: '...', price: '...', description: '' }
];
// product temptate
.product
.product__title=outerObj.title
.product__price=outerObj.price
.product__description=outerObj.description
どのように「製品テンプレート」を含めると、ループ内でパラメータを渡すことができますか?
// example of regular usage of 'product template':
- for (var i = 0; i < outerObj.length; i++)
// pass only outerObj[i]
include ./path/to/product-template.jade'
それは私の問題を解決します。ありがとう! –