Created
August 25, 2012 19:32
-
-
Save arnaud-lb/3469893 to your computer and use it in GitHub Desktop.
MtHaml attributes example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ -------------------------------------------------- | |
/ when value is false (or null), attr isn't rendered | |
/ -------------------------------------------------- | |
%input(type="checkbox" checked=false) | |
%div(class=(false ? false : "test")) | |
/ <input type="checkbox" /> | |
/ <div></div> | |
/ ---------------------------------------------------- | |
/ when value is true, attr is rendered as boolean attr | |
/ ---------------------------------------------------- | |
%input(type="checkbox" checked=true) | |
/ html5: | |
/ <input type="checkbox" checked /> | |
/ xhtml: | |
/ <input type="checkbox" checked="checked" /> | |
/ ---------------------------------------------------- | |
/ data attrs | |
/ ---------------------------------------------------- | |
%div(data={foo: "bar", bar: "baz", qux: false ? false : "test"}) | |
/ <div type="checkbox" data-foo="bar" data-bar="baz"></div> | |
/ ---------------------------------------------------- | |
/ ids | |
/ ---------------------------------------------------- | |
%div#foo(id=["bar", "baz", false ? false : "test"]) | |
/ <div id="foo_bar_baz" /> | |
/ ---------------------------------------------------- | |
/ classes | |
/ ---------------------------------------------------- | |
%div.foo(class=["bar", "baz", false ? false : "test"]) | |
/ <div class="foo bar baz" /> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment