【发布时间】:2014-01-23 15:00:38
【问题描述】:
例如,假设我有一个 mixin 来创建博客文章:
mixin blogPost(title, content)
article
h1= title
p= content
这样使用:
+blogPost("Post Title","Post Content")
结果:
<article>
<h1>Post Title</h1>
<p>Post Content</p>
</article>
效果很好,但假设我不知道帖子的“帖子内容”部分有多少段,我只知道会有一个或多个。因此,例如,帖子的内容可能是:
**Title**
My awesome blog post
**Post Content**
This is my awesome blog post.
This is a new paragraph about my awesome blog post.
这样的东西可以解决问题吗?
mixin blogPost(title, content)
article
h1= title
- for each paragraph in content
p= content
这样称呼:
+blogPost("Post Title", {"This is my awesome blog post.","This is a new paragraph about my awesome blog post."})
这行得通吗?有没有更好的办法?
【问题讨论】:
标签: html templates pug template-mixins