[英]Parent - child templates (dust.js)
請幫助模板。
對於ex我有3個模板:
<!-- comment -->
<div>{message}</div>
<!-- comment list -->
<div class="comment-list">{+content}No comments{/content}</div>
<!-- wrapper -->
<div class="wrapper">{+content/}</div>
顯示為:
-wrapper
--comments-list
---comment
我嘗試:
{<content}
{#comments}
{>comment/}
{/comments}
{/content}
{<content}
{>comment-list /}
{/content}
{>worklet/}
但這行不通。 我做錯了什么?
我可以看到一些可能的問題:
{! First definition of the inline partial "content" !}
{<content}
{#comments}
{>comment/}
{/comments}
{/content}
{! Second definition inline partial "content" will over-write the first definition !}
{<content}
{>comment-list /}
{/content}
{! You are including a partial called "worklet", but where is this partial
defined. In your example, you call it "wrapper" !}
{>worklet/}
這是一種可能滿足您需要的替代方法:
{! wrapper template !}
<div class="wrapper">
{?comments}
<ul class="comment-list">
{#comments}
{>comment/}
{/comment}
</ul>
{:else}
No comments.
{/comments}
</div>
和評論模板:
{! comment template !}
<li>{message}</li>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.