Pug嵌入

普通变量直接嵌入

- var title = "On Dogs: Man's Best Friend";
- var author = "enlore";
- var theGreat = "<span>转义!</span>";

h1= title
p #{author} 笔下源于真情的创作。
p 这是安全的:#{theGreat}

等价于-->
<h1>On Dogs: Man's Best Friend</h1>
<p>enlore 笔下源于真情的创作。</p>
<p>这是安全的:&lt;span&gt;转义!&lt;/span&gt;</p>

Js表达式嵌入

- var msg = "not my inside voice";
p This is #{msg.toUpperCase()}

等价于-->
<p>This is NOT MY INSIDE VOICE</p>

字符串嵌入,不转义

- var riskyBusiness = "<em>我希望通过外籍教师 Peter 找一位英语笔友。</em>";
.quote
  p 李华:!{riskyBusiness}

等价于-->
<div class="quote">
  <p>李华:<em>我希望通过外籍教师 Peter 找一位英语笔友。</em></p>
</div>

猜你喜欢

转载自www.cnblogs.com/xqxacm/p/12365069.html
pug