LoginSignup
2
1

More than 5 years have passed since last update.

gulpでpugをコンパイルしたときにリンクの&がエスケープされるのをやめたい

Posted at

結論:! をつけよう

hoge.pug
a(href!="https://hogesite.com&piyo") ほげサイト

a(href!="")のように、!をつけることで回避できます。

現象

hoge.pug
a(href="https://hogesite.com&piyo") ほげサイト

↑これをコンパイルした際、

hoge.html
<a href="https://hogesite.com&amp;piyo">ほげサイト</a>

&&amp;となってしまったピヨ。
エスケープされることが普通なので、コンパイラは悪くないのですが、クライアントからエスケープしないで欲しいとNGが。

これを回避するには最初に書いたように、

hoge.pug
a(href!="https://hogesite.com&piyo") ほげサイト

hrefのあとに!を付けましょう!

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1