| 1 | <h2>Comments</h2> |
| 2 | <pre><code> |
| 3 | / This is comment |
| 4 | on multiple lines |
| 5 | / This is a comment |
| 6 | but this is not |
| 7 | -# This is another comment |
| 8 | on multiple lines</code></pre> |
| 9 | |
| 10 | <h2>Doctype</h2> |
| 11 | <pre><code>!!! XML |
| 12 | !!! |
| 13 | !!! 5</code></pre> |
| 14 | |
| 15 | <h2>Tags</h2> |
| 16 | <pre><code>%div |
| 17 | %span |
| 18 | %span(class="widget_#{@widget.number}") |
| 19 | %div{:id => [@item.type, @item.number], :class => [@item.type, @item.urgency]} |
| 20 | %html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"} |
| 21 | %html{html_attrs('fr-fr')} |
| 22 | %div[@user, :greeting] |
| 23 | %img |
| 24 | %pre>< |
| 25 | foo |
| 26 | bar |
| 27 | %img |
| 28 | </code></pre> |
| 29 | |
| 30 | <h2>Markup</h2> |
| 31 | <pre><code>%div |
| 32 | <p id="blah">Blah!</p></code></pre> |
| 33 | |
| 34 | <h2>Inline Ruby</h2> |
| 35 | <pre><code>= ['hi', 'there', 'reader!'].join " " |
| 36 | - foo = "hello" |
| 37 | = link_to_remote "Add to cart", |
| 38 | :url => { :action => "add", :id => product.id }, |
| 39 | :update => { :success => "cart", :failure => "error" } |
| 40 | ~ "Foo\n<pre>Bar\nBaz</pre>" |
| 41 | %p |
| 42 | - case 2 |
| 43 | - when 1 |
| 44 | = "1!" |
| 45 | - when 2 |
| 46 | = "2?" |
| 47 | - when 3 |
| 48 | = "3." |
| 49 | - (42...47).each do |i| |
| 50 | %p= i |
| 51 | %p See, I can count! |
| 52 | </code></pre> |
| 53 | |
| 54 | <h2>Filters</h2> |
| 55 | |
| 56 | <pre><code>%head |
| 57 | :css |
| 58 | #content: { |
| 59 | background: url('img/background.jpg'); |
| 60 | } |
| 61 | div { |
| 62 | color: #333; |
| 63 | } |
| 64 | :javascript |
| 65 | (function() { |
| 66 | var test = "Do you like Prism?"; |
| 67 | if(confirm(test)) { |
| 68 | do_something_great(); |
| 69 | } |
| 70 | }()); |
| 71 | %body |
| 72 | </code></pre> |
| 73 | |
| 74 | <p>Filters require the desired language to be loaded. |
| 75 | On this page, check CoffeeScript <strong>before</strong> checking Haml should make |
| 76 | the example below work properly.</p> |
| 77 | <pre><code>%script |
| 78 | :coffee |
| 79 | console.log 'This is coffee script'</code></pre> |