渲染包含脚本标签的 pug 变量
Render pug variable which contains a script tag
我做了很多研究来呈现包含 Google Analytics 标签的变量:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-******-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-******-1');
</script>
我知道这是可能的:
script.
#{codeAnalytics}
但是它会在标签内打印标签。
是否可以像这样使用它:
#{codeGTM}
这将打印分析标签
适用于:
.
!{codeGTM}
注意我们需要“!”而不是将脚本标记解释为 html 标记的“#”。
我做了很多研究来呈现包含 Google Analytics 标签的变量:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-******-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-******-1');
</script>
我知道这是可能的:
script.
#{codeAnalytics}
但是它会在标签内打印标签。
是否可以像这样使用它:
#{codeGTM}
这将打印分析标签
适用于:
.
!{codeGTM}
注意我们需要“!”而不是将脚本标记解释为 html 标记的“#”。