为哈巴狗改造管道?

问题描述 投票:0回答:1

用例是我有一个非常简单的哈巴狗文档。我需要创建两个文档...一个是原始文档,另一个是使“私有”标签模糊不清的文档。为了以编程方式执行此操作,我需要能够遍历所有标签。 pug API是否提供该功能?

h1 
  private Foobar
p
  Lorem ipsum
pug
1个回答
0
投票

tags.pug

-
    let tags = [
        {
            tag: "h1",
            private: true,
            content: "private Foobar"
        },
        {
             tag: "p",
             content: "Lorem ipsum"
        }
    ]

public.pug

 include tags.pug

 each tag in tags
      if !tag.private
          ...etc

private.pug

 include tags.pug

 each tag in tags
      ...etc
© www.soinside.com 2019 - 2024. All rights reserved.