我们正在使用node版Pattern Lab为我们的新网站构建生成样式指南,我们也希望利用我们电子商务中的Pattern Lab生成的模板文件平台的模板。
有没有办法创建另一个版本的Pattern Lab模板,而不会在编译后出现生成的标记和Node标签?
例如,我们有一个名为main.mustache的PL模板。当我们的PL grunt监视任务运行时,生成的模板最终在patternlab \ public \ patterns \ 30-templates-main-main文件夹中作为html文件,内容如此......
<!-- Start: REMOVE THIS -->
<!DOCTYPE html>
<html class="pl">
<head>
<title>My Component Library</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
<!--<link rel="stylesheet" href="../../css/style.css?1462369182849" media="all" />-->
<!-- Begin Pattern Lab (Required for Pattern Lab to run properly) -->
<!-- never cache patterns -->
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<link rel="stylesheet" href="../../styleguide/css/styleguide.css?1462369182849" media="all">
<link rel="stylesheet" href="../../styleguide/css/styleguide-specific.css?1462369182849" media="all" />
<!-- End Pattern Lab -->
</head>
<body class="body">
<!-- End: REMOVE THIS -->
**[ TEMPLATE CONTENT CODE IS HERE WHICH I WANT... ]**
<!-- Start: REMOVE THIS -->
<!--DO NOT REMOVE-->
<!-- DO NOT MODIFY -->
<script>
// handle injection of items from Node
var patternPartial = "templates-main";
var lineage = [{lineagePattern:"organisms-messages",lineagePath:"../../patterns/20-organisms-global-messages/20-organisms-global-messages.html"},{lineagePattern:"organisms-header",lineagePath:"../../patterns/20-organisms-global-header/20-organisms-global-header.html"},{lineagePattern:"organisms-promotion-messages",lineagePath:"../../patterns/20-organisms-global-promotion-messages/20-organisms-global-promotion-messages.html"},{lineagePattern:"molecules-search",lineagePath:"../../patterns/10-molecules-forms-search/10-molecules-forms-search.html"},{lineagePattern:"organisms-footer",lineagePath:"../../patterns/20-organisms-global-footer/20-organisms-global-footer.html"}];
var lineageR = [{lineagePattern:"pages-main",lineagePath:"../../patterns/40-pages-main/40-pages-main.html"}];
var patternState = "";
var baseurl = "";
var cssEnabled = false; //TODO
</script>
<script type="text/html" id="sg-pattern-html">
{% patternHTML %}
</script>
<script type="text/html" id="sg-pattern-css">
{% patternCSS %}
</script>
<script src="../../styleguide/js/vendor/jwerty.js?1462369182849"></script>
<script src="../../styleguide/js/postmessage.js?1462369182849"></script>
<script src="../../data/annotations.js?1462369182849"></script>
<script src="../../styleguide/js/annotations-pattern.js?1462369182849"></script>
<script src="../../styleguide/js/code-pattern.js?1462369182849"></script>
</body>
</html>
<!-- End: REMOVE THIS -->
如果没有附加标记的版本,那就太棒了(请参阅内部&#39;删除此上面的注释),因此我们只需使用生成的模板html进行构建我们的生物,分子和原子等。
答案 0 :(得分:2)
在同一文件夹中始终存在转义的转义版本。以你为榜样
patternlab\public\patterns\30-templates-main-main
将包含:
30-templates-main-main.html
- 带有附加标记的代码段(页眉+页脚)30-templates-main-main.mustache
- 转义.mustache(带变量),无其他标记30-templates-main-main.escaped.html
- 转义HTML,无其他标记 .mustache
和.escaped.html
都只包含代码段内容,没有其他标记。请注意,这两个文件都包含转义的HTML,因此在进一步使用HTML之前不要忘记将HTML转发回来。这可以通过多种方式完成,具体取决于您的语言,即有一个NPM模块可以解码转义文本中的HTML:https://www.npmjs.com/package/html-entities