![](/img/trans.png)
[英]FreeMarker Template Language (FTL): Split Multivalue XML Field Metadata to Group Respective Values
[英]Pandoc: Template with YAML metadata
我使用pandoc生成帶有YAML元數據的index.html。 我知道pandoc模板中的迭代關聯數組:
YAML :
- Author: Mastropiero
- Author: Gunter Fraggen
模板 :
$for(author)$
$author$
$endfor$
但是......如何在沒有密鑰的情況下迭代列表?
YAML :
- Author:
- [Value1, Value2]
- [Value1B, Value2B]
模板 :
$for(author)$
... // how works?
$endfor$
正如您的模板所示,在一個循環中,pandoc會生成一個與數組同名的局部變量(在您的情況下為“author”)。 因此,要迭代內部列表,只需在內部變量上使用相同的“for”機制。
因此,你應該使用
模板
$for(author)$
$for(author)$
$author$
$endfor$
$endfor
您還可以使用$ sep $指定要在列表元素之間使用的分隔符。
請注意,如果內部列表具有不同含義的元素(而不僅僅是列表),那么您應該使用字典列表。
YAML
Author:
- {name: Iain Banks, book: The Algebraist}
- {name: Isaac Asimov, book: Foundation}
模板
$for(author)$
$author.name$ wrote $author.book$
$endfor$
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.