[英]How to add a class for html tag (<span>) depending a condition with javascript
[英]Pug - how to add a span tag with a class into a mixins argument
帕格模板-如何將帶有類的跨度標簽作為內插添加到mixins參數中以包圍一個單詞,以便我可以以不同的方式設置樣式?
這是_section-headline.pug中的mixin:
mixin section-headline(tagline, title, description, idSection)
section.section(id=idSection)
.container
.row.row--tablet-center
.col-xs-12.col-sm-10.col-md-12.col-lg-10
.headline
div.headline__top-line
p.headline__tagline=tagline
h1.headline__title=title
p.headline__description=description
我稱它為team.pug:
doctype html
include ./includes/global/_landing.pug
include ./includes/global/_section-headline.pug *<-- including here*
html
head
<meta charset="UTF-8">
<title>Team - Cerv PC</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/png" href="/images/favicon.png">
body
- var greenText = "<span call="type--color-green">language</span>";
+section-headline('guided by diveristy', 'We speak your '+ greenText +', 'We offer personal injury legal services in Hindi, Punjabi, and Urdu. We are happy to accommodate clients speaking other languages through the use of interpreters.', 'contact-us')
因此,我正在嘗試將帶有/不帶文本的span標記放入mixin參數中,因此我只將一個單詞設為綠色,而不是全部。 這個怎么做? 嘗試了幾件事,但似乎無濟於事。
我試過了!
采用
h1.headline__title !{title}
代替
h1.headline__title=title OR h1.headline__title=!{title}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.