Pug.jsフィルタ内の値をバインドしたいと思います。しかし、そのフィルタはうまく動作しますが、値がバインドされません。Pug.jsフィルタ内の値をバインドする方法
出力結果フィルタと
<style>.#{cs_1}{font-family:monospace !important;color:#a1292c !important}.#{cs_1}:hover{background-color:transparent !important;text-decoration:underline !important}.#{cs_2}{position:absolute;font-size:11px;text-transform:none;left:80px;top:12px;border-left:1px solid #ccc;padding-left:6px}.#{cs_3}{white-space:nowrap}</style>
出力結果フィルターなし
<style>
.eTWkI {
font-family: monospace !important;
color: #a1292c !important;
}
.eTWkI:hover {
background-color: transparent !important;
text-decoration: underline !important;
}
.Rzorr {
position: absolute;
font-size: 11px;
text-transform: none;
left: 80px;
top: 12px;
border-left: 1px solid #ccc;
padding-left: 6px;
}
.vMvwp {
white-space: nowrap;
}
</style>
Pug.jsコード
ありませんE:
:minifycss
フィルタは
- var length = 5
- var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz_-"
- var cs_1 = utils.randomString(length, chars)
- var cs_2 = utils.randomString(length, chars)
- var cs_3 = utils.randomString(length, chars)
style
:minifycss
.#{cs_1} {
font-family: monospace !important;
color: #a1292c !important;
}
.#{cs_1}:hover {
background-color: transparent !important;
text-decoration: underline !important;
}
.#{cs_2} {
position: absolute;
font-size: 11px;
text-transform: none;
left: 80px;
top: 12px;
border-left: 1px solid #ccc;
padding-left: 6px;
}
.#{cs_3} {
white-space: nowrap;
}
だからフィルターがどのように見えるuglifycssモジュールを作った:パグフィルターはコンパイル時に実行され、およびすることができませんように見えます
require('pug').filters = {
minifycss: (text, options) => {
if (!text) return;
return uglifycss.processString(text, options);
}
};
コードの実際の出力はどのくらいですか?それは何もないか、それとも予期せぬ出力ですか? @SheaBelsky。 –
いいえ、エラーはありません。ただ出力結果のみ – DININDU