有沒有辦法獲取在手寫筆規則集中匹配的類的名稱?哪個選擇符與手寫筆規則集匹配?
我想要做的就是乾燥了這個規則(和許多喜歡它):
.button
&:hover
button-hover-color-scheme(teal)
&.adwords
button-hover-color-scheme(adwords)
&.bingads
button-hover-color-scheme(bingads)
&.facebook
button-hover-color-scheme(facebook)
&.linkedin
button-hover-color-scheme(linkedin)
&.twitter
button-hover-color-scheme(twitter)
我想使它看起來像這樣:
.button
&:hover
button-hover-color-scheme(teal)
&.adwords
&.bingads
&.facebook
&.linkedin
&.twitter
button-hover-color-scheme(matched-selector)
哪裏matched-selector
將是adwords, bingads, facebook, linkedin, or twitter
實際上與規則匹配的那一個。
謝謝!
編輯:
還有就是selector()功能,但它給了我整個選擇而不僅僅是最後一塊相匹配。這幾乎是我所需要的,但我覺得必須有一種更簡單的方式來引用匹配的選擇器。
謝謝。這很有意義,並幫助我以正確的方式思考這個問題。也許我可以嘗試[插入](http://learnboost.github.io/stylus/docs/interpolation.html#selector-interpolation)來獲得我想要的。 – spinlock
是的,避免這種重複的唯一方法是插入+循環。 – Panya