例如,假设我有一个 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."})
这行得通吗?有没有更好的办法?