1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
%title
= @title
\= @title
%script{
"type": "text/javascript",
"src": "javascripts/script_#{2 + 7}",
"data": {
"controller": "reporter",
},
}
%div{:id => [@item.type, @item.number], :class => [@item.type, @item.urgency]}
%div{:id => "#{@item.type}_#{@item.number}", :class => "#{@item.type} #{@item.urgency}"}
.item{:class => @item.is_empty? && "empty"}
%a(title=@title href=href) Stuff
%a(title=@title){:href => @link.href} Stuff
%a{:href=>"/posts", :data => {:author_id => 123, :category => 7}} Posts By Author
.book-info{:data => {:book => {:id => 123, :genre => 'programming'}, :category => 7}}
%div#things
%span#rice Chicken Fried
%p.beans{ :food => 'true' } The magical fruit
%h1.class.otherclass#id La La La
%br/
%meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/
%p[user]{:class => 'alpha bravo'}
%blockquote<
%div
Foo!
%img
%img>
%img
%img
%pre><
foo
bar
%img
-# file: app/views/users/show.haml
%p
hello
%div[@user, :greeting]
%bar[290]/
Hello!
- user = User.find(1)
.foo.moo{:class => ['bar', 'alpha']}(class='baz')
!!! XML
%peanutbutterjelly
/ This is the peanutbutterjelly element
I like sandwiches!
/
%p This doesn't render...
%div
%h1 Because it's commented out!
%p
/[if IE]
%a{ :href => 'http://www.mozilla.com/en-US/firefox/' }
%h1 Get Firefox
%p foo
-# This is a comment
%p bar
%p foo
-#
This won't be displayed
Nor will this
Nor will this.
%p bar
%p
= ['hi', 'there', 'reader!'].join " "
= "yo"
= link_to_remote "Add to cart",
:url => { :action => "add", :id => product.id },
:update => { :success => "cart", :failure => "error" }
- foo = "hello"
- foo << " there"
- foo << " you!"
%p= foo
- links = {:home => "/",
:docs => "/docs",
:about => "/about"}
- (42...47).each do |i|
%p= i
%p See, I can count!
%p
- case 2
- when 1
= "1!"
- when 2
= "2?"
- when 3
= "3."
~ "Foo\n<pre>Bar\nBaz</pre>"
%p This is #{h quality} cake!
%p
Look at \\#{h word} lack of backslash: \#{foo}
And yon presence thereof: \{foo}
&= "I like cheese & crackers"
& I like #{"cheese & crackers"}
= "I feel <strong>!"
!= "I feel <strong>!"
! I feel #{"<strong>"}!
%whoo
%hoo= h( |
"I think this might get " + |
"pretty long so I should " + |
"probably make it " + |
"multiline so it doesn't " + |
"look awful.") |
%p This is short.
!!!
%html{ :xmlns => "http://www.w3.org/1999/xhtml", :lang => "en", "xml:lang" => "en"}
%head
%title BoBlog
%meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}
%meta(http-equiv="Content-Type" content = "text/html; charset=utf-8" class=21 id='d3')
%link{rel: 'stylesheet', href: 'main.css', type: 'text/css'}
:css
body {
font-size: 16px;
margin-top: 0px;
margin-bottom: 0px;
font-family: Arial, sans-serif;
}
p {
margin: 0px;
padding: 0px;
}
%body
#header
%a{
href: root_path,
name: "home"
}
%h1 BoBlog
%h2 Bob's Blog
#content
- @entries.each do |entry|
.entry{ id: entry.id }
%h3.title= entry.title
%p.date
Posted on #{entry.posted.strftime("%A, %B %d, %Y")}
%p.body= entry.body
= button_to "Load more", entries_path,
class: "btn btn-primary",
method: :get,
params: { last_id: @entries.map(&:id).min },
form: { data: { turbo_stream: true } }
:ruby
provide(:title, user_title(@user))
provide(:og, user_opengraph(@user))
provide(:meta, user_twitter_card(@user))
parent_layout 'user/profile'
#footer
%p
All content copyright © Bob
#filterTest
%p Just testing some more HAML filters
:coffee
window.alert "Hello from CoffeeScript #{1}"
:coffeescript
window.alert "Hello from CoffeeScript again, #{1 + 1}"
:css
#filterTest {
display: none;
}
:erb
For some reason <%= "ERB works too #{@abcdef}" %>.
:plain
Anything else should be treated as plain text.
This also means that the following shouldn't be highlighted:
%h1#superawesomeheading Heading 1
%div Filter test done
|