LoginSignup
1
0

More than 5 years have passed since last update.

[jade]横着メモ

Last updated at Posted at 2014-09-09

個人用メモとして。

mixin

<div class="hogeclass">hogeText</div>
<div class="hogeclass">piyoText</div>

を書くのに

 - var strs = ["hogeText","piyoText"]
 - for (var i=0; i < strs.length; i++){
 .hogeclass #{strs[i]}
 - }

でもいいけど,

mixin list(arr)
 each item in arr
  div(class=attributes.class)= item

+list(["hogeText","piyoText"]).hogeClass

の方が,jadeっぽい?

  • .(attributes.class) と書きたかったけど,解釈してくれなかった
  • .attributes.class<div class=”attributes class"></div>に展開された。そりゃそーか。
  • eachの構文は構文で注意。 divの後の=を忘れると,"item"と,そのまま展開される。 (これは別のルールかな)

Syntax suger

暗黙のdiv

<div id='hoge' attr='piyo'></div>

を簡単に出力したい

#hoge(attr='piyo')

mixin

mixin hoge
+hoge

同じ

1
0
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
1
0