2017-10-27 6 views
0

.dustファイルに「@select」の使用にハッシュマップのネストされた配列をレンダリング:"uniquekey"の各値に基づいて私のようにハッシュマップの配列を含むJSONオブジェクト持って

{ "someparentkey": { 
     "arraykey": [ 
      { 
       "uniquekey": "key1", 
       "content": "param1" 
      }, 
      { 
       "uniquekey": "key2", 
       "content": "param2" 
      } 
     ] 
    } 
} 

を、私はレンダリングしますインポートされたホコリテンプレートに渡された値が"content"の別のホコリテンプレート。

これが私の基本テンプレートは、今のように見えるものです:

{#someparentkey} 
    {#arraykey} 
     {@select key={uniquekey} } 
      {@eq value="key1"}{>"path/to/dust1" param={content} /}{/eq} 
      {@eq value="key2"}{>"path/to/dust2" param={content} /}{/eq} 
      {@default}<!-- Invalid script tag {key} in configuration -->{/default} 
     {/select} 
    {/arraykey} 
{/someparentkey} 

そして、私のインポートテンプレート(「パス/に/ dust1.dust」と「パス/に/ dust1.dustは」)のようなものです:

として
<span>{param}</span> 

しかし、ダストファイルの"うなり声のビルド"をしながら、私はエラーを取得しています:

SyntaxError: Expected end tag for arraykey but it was not found. At line : 3, column : 9 Blockquote

Warning: Dust.js failed to compile template "path/to/my/base-dust".

件の

質問:

  1. 私の現在のテンプレートコードでは問題は何ですか?
  2. そして、私が欲しいものを達成するためのより良い方法はありますか?

答えて

0

これは私が最終的に使用してしまった、それは私のために働いたテンプレートです:

{#someparentkey.arraykey} 
    {@select key=uniquekey } 
     {@eq value="key1"}{>"path/to/dust1" param=content /}{/eq} 
     {@eq value="key2"}{>"path/to/dust2" param=content /}{/eq} 
     {@default}<!-- Invalid script tag {key} in configuration -->{/default} 
    {/select} 
{/someparentkey.arraykey} 
関連する問題