Skip to content

Commit fadeb25

Browse files
author
murphy
committed
add HAML scanner tests
1 parent 08fef24 commit fadeb25

File tree

5 files changed

+636
-0
lines changed

5 files changed

+636
-0
lines changed

haml/example.expected.raydebug

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
doctype(!!!)
2+
constant(#main)
3+
class(.note)
4+
tag(%h2) plain(Quick Notes)
5+
tag(%ul)
6+
tag(%li)
7+
plain(Haml is usually indented with two spaces,)
8+
plain(although more than two is allowed.)
9+
plain(You have to be consistent, though.)
10+
tag(%li)
11+
plain(The first character of any line is called )
12+
plain(the "control character" - it says "make a tag")
13+
plain(or "run Ruby code" or all sorts of things.)
14+
tag(%li)
15+
plain(Haml takes care of nicely indenting your HTML.)
16+
tag(%li)
17+
plain(Haml allows Ruby code and blocks.)
18+
plain(But not in this example.)
19+
plain(We turned it off for security.)
20+
21+
class(.note)
22+
plain(You can get more information by reading the)
23+
tag(%a)plain({)symbol(:href) operator(=)operator(>) string<delimiter(")content(/docs/yardoc/file.HAML_REFERENCE.html)delimiter(")>plain(})
24+
plain(Official Haml Reference)
25+
26+
class(.note)
27+
tag(%p)
28+
plain(This example doesn't allow Ruby to be executed,)
29+
plain(but real Haml does.)
30+
tag(%p)
31+
plain(Ruby code is included by using = at the)
32+
plain(beginning of a line.)
33+
tag(%p)
34+
plain(Read the tutorial for more information.)
35+
36+
tag(%strong)plain(= )ident(item)operator(.)ident(title)
37+
38+
tag(%strong)plain({)symbol(:class) operator(=)operator(>) string<delimiter(")content(code)delimiter(")>operator(,) symbol(:id) operator(=)operator(>) string<delimiter(")content(message)delimiter(")>plain(}) plain(Hello, World!)
39+
40+
tag(%strong)class(.code)constant(#message) plain(Hello, World!)
41+
42+
class(.content) plain(Hello, World!)
43+
44+
class(.item)plain({)symbol(:id) operator(=)operator(>) string<delimiter(")content(item)inline<inline_delimiter(#{)ident(item)operator(.)ident(id)inline_delimiter(})>delimiter(")>plain(})plain(= )ident(item)operator(.)ident(body)
45+
46+
constant(#content)
47+
class(.left)class(.column)
48+
tag(%h2) plain(Welcome to our site!)
49+
tag(%p)plain(= )ident(print_information)
50+
class(.right)class(.column)
51+
plain(= )ident(render) symbol(:partial) operator(=)operator(>) string<delimiter(")content(sidebar)delimiter(")>

haml/example.in.haml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
!!!
2+
#main
3+
.note
4+
%h2 Quick Notes
5+
%ul
6+
%li
7+
Haml is usually indented with two spaces,
8+
although more than two is allowed.
9+
You have to be consistent, though.
10+
%li
11+
The first character of any line is called
12+
the "control character" - it says "make a tag"
13+
or "run Ruby code" or all sorts of things.
14+
%li
15+
Haml takes care of nicely indenting your HTML.
16+
%li
17+
Haml allows Ruby code and blocks.
18+
But not in this example.
19+
We turned it off for security.
20+
21+
.note
22+
You can get more information by reading the
23+
%a{:href => "/docs/yardoc/file.HAML_REFERENCE.html"}
24+
Official Haml Reference
25+
26+
.note
27+
%p
28+
This example doesn't allow Ruby to be executed,
29+
but real Haml does.
30+
%p
31+
Ruby code is included by using = at the
32+
beginning of a line.
33+
%p
34+
Read the tutorial for more information.
35+
36+
%strong= item.title
37+
38+
%strong{:class => "code", :id => "message"} Hello, World!
39+
40+
%strong.code#message Hello, World!
41+
42+
.content Hello, World!
43+
44+
.item{:id => "item#{item.id}"}= item.body
45+
46+
#content
47+
.left.column
48+
%h2 Welcome to our site!
49+
%p= print_information
50+
.right.column
51+
= render :partial => "sidebar"

haml/reference.expected.raydebug

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
doctype(!!! XML)
2+
doctype(!!! XML iso-8859-1)
3+
doctype(!!!)
4+
tag(%html)
5+
tag(%head)
6+
tag(%title) plain(Myspace)
7+
tag(%body)
8+
tag(%h1) plain(I am the international space station)
9+
tag(%p) plain(Sign my guestbook)
10+
11+
plain(-)comment(# file: app/views/movies/index.haml)
12+
13+
constant(#content)
14+
class(.title)
15+
tag(%h1)plain(= )instance_variable(@title)
16+
plain(= )ident(link_to) string<delimiter(')content(Home)delimiter(')>operator(,) ident(home_url)
17+
18+
tag(%gee)
19+
tag(%whiz)
20+
plain(Wow this is cool!)
21+
22+
tag(%p)
23+
tag(<div) attribute_name(id)operator(=)string<delimiter(")content(blah)delimiter(")>tag(>)plain(Blah!)tag(</div>)
24+
25+
tag(<gee>)
26+
tag(<whiz>)
27+
plain(Wow this is cool!)
28+
tag(</whiz>)
29+
tag(</gee>)
30+
31+
tag(%title)
32+
plain(= )instance_variable(@title)
33+
plain(\\)plain(= @title)
34+
35+
tag(%one)
36+
tag(%two)
37+
tag(%three) plain(Hey there)
38+
39+
tag(%html)plain({)symbol(:xmlns) operator(=)operator(>) string<delimiter(")content(http://www.w3.org/1999/xhtml)delimiter(")>operator(,) string<delimiter(")content(xml:lang)delimiter(")> operator(=)operator(>) string<delimiter(")content(en)delimiter(")>operator(,) symbol(:lang) operator(=)operator(>) string<delimiter(")content(en)delimiter(")>plain(})
40+
41+
tag(%script)plain({)symbol(:type) operator(=)operator(>) string<delimiter(")content(text/javascript)delimiter(")>operator(,)
42+
symbol(:src) operator(=)operator(>) string<delimiter(")content(javascripts/script_)inline<inline_delimiter(#{)integer(2) operator(+) integer(7)inline_delimiter(})>delimiter(")>plain(})
43+
44+
tag(%div)plain({)symbol(:id) operator(=)operator(>) operator([)instance_variable(@item)operator(.)ident(type)operator(,) instance_variable(@item)operator(.)ident(number)operator(])operator(,) symbol(:class) operator(=)operator(>) operator([)instance_variable(@item)operator(.)ident(type)operator(,) instance_variable(@item)operator(.)ident(urgency)operator(])plain(})
45+
tag(%div)plain({)symbol(:id) operator(=)operator(>) string<delimiter(")inline<inline_delimiter(#{)instance_variable(@item)operator(.)ident(type)inline_delimiter(})>content(_)inline<inline_delimiter(#{)instance_variable(@item)operator(.)ident(number)inline_delimiter(})>delimiter(")>operator(,) symbol(:class) operator(=)operator(>) string<delimiter(")inline<inline_delimiter(#{)instance_variable(@item)operator(.)ident(type)inline_delimiter(})>content( )inline<inline_delimiter(#{)instance_variable(@item)operator(.)ident(urgency)inline_delimiter(})>delimiter(")>plain(})
46+
47+
tag(%div)plain({)symbol(:class) operator(=)operator(>) operator([)instance_variable(@item)operator(.)ident(type)operator(,) instance_variable(@item) operator(==) instance_variable(@sortcol) operator(&&) operator([)symbol(:sort)operator(,) instance_variable(@sortdir)operator(])operator(]) plain(}) plain(Contents)
48+
49+
class(.item)plain({)symbol(:class) operator(=)operator(>) instance_variable(@item)operator(.)ident(is_empty?) operator(&&) string<delimiter(")content(empty)delimiter(")>plain(})
50+
51+
tag(%html)plain(()attribute_name(xmlns)operator(=)string<delimiter(")content(http://www.w3.org/1999/xhtml)delimiter(")> attribute_name(xml:lang)operator(=)string<delimiter(")content(en)delimiter(")> attribute_name(lang)operator(=)string<delimiter(")content(en)delimiter(")>plain(\))
52+
53+
tag(%a)plain(()attribute_name(title)operator(=)error(@)attribute_value(title) attribute_name(href)operator(=)attribute_value(href)plain(\)) plain(Stuff)
54+
tag(%a)plain({)symbol(:title) operator(=)operator(>) instance_variable(@title)operator(,) symbol(:href) operator(=)operator(>) ident(href)plain(}) plain(Stuff)
55+
tag(%a)plain(()attribute_name(title)operator(=)error(@)attribute_value(title)plain(\))plain({)symbol(:href) operator(=)operator(>) instance_variable(@link)operator(.)ident(href)plain(}) plain(Stuff)
56+
tag(%span)plain(()attribute_name(class)operator(=)string<delimiter(")content(widget_#{@widget.number})delimiter(")>plain(\))
57+
tag(%script)plain(()attribute_name(type)operator(=)string<delimiter(")content(text/javascript)delimiter(")>
58+
attribute_name(src)operator(=)string<delimiter(")content(javascripts/script_#{2 + 7})delimiter(")>plain(\))
59+
60+
tag(%html)plain({)ident(html_attrs)operator(()string<delimiter(')content(fr-fr)delimiter(')>operator(\))plain(})
61+
62+
tag(%sandwich)plain({)ident(hash1)operator(,) ident(hash2)operator(,) symbol(:delicious) operator(=)operator(>) predefined_constant(true)plain(})tag(/)
63+
64+
tag(%input)plain({)symbol(:selected) operator(=)operator(>) predefined_constant(true)plain(})
65+
tag(%input)plain({)symbol(:selected) operator(=)operator(>) predefined_constant(false)plain(})
66+
67+
tag(%input)plain(()attribute_name(selected)plain(\))
68+
tag(%input)plain(()attribute_name(selected)operator(=)attribute_value(true)plain(\))
69+
70+
tag(%a)plain({)symbol(:href)operator(=)operator(>)string<delimiter(")content(/posts)delimiter(")>operator(,) symbol(:data) operator(=)operator(>) operator({)symbol(:author_id) operator(=)operator(>) integer(123)operator(})plain(}) plain(Posts By Author)
71+
72+
tag(%div)constant(#things)
73+
tag(%span)constant(#rice) plain(Chicken Fried)
74+
tag(%p)class(.beans)plain({) symbol(:food) operator(=)operator(>) string<delimiter(')content(true)delimiter(')> plain(}) plain(The magical fruit)
75+
tag(%h1)class(.class)class(.otherclass)constant(#id) plain(La La La)
76+
77+
tag(%div)constant(#content)
78+
tag(%div)class(.articles)
79+
tag(%div)class(.article)class(.title) plain(Doogie Howser Comes Out)
80+
tag(%div)class(.article)class(.date) plain(2006-11-05)
81+
tag(%div)class(.article)class(.entry)
82+
plain(Neil Patrick Harris would like to dispel any rumors that he is straight)
83+
84+
tag(%div)constant(#Article)class(.article)class(.entry)plain({)symbol(:id) operator(=)operator(>) instance_variable(@article)operator(.)ident(number)operator(,) symbol(:class) operator(=)operator(>) instance_variable(@article)operator(.)ident(visibility)plain(})
85+
tag(%div)plain({)symbol(:id) operator(=)operator(>) operator([)string<delimiter(')content(Article)delimiter(')>operator(,) instance_variable(@article)operator(.)ident(number)operator(])operator(,) symbol(:class) operator(=)operator(>) operator([)string<delimiter(')content(article)delimiter(')>operator(,) string<delimiter(')content(entry)delimiter(')>operator(,) instance_variable(@article)operator(.)ident(visibility)operator(])plain(}) plain(Gabba Hey)
86+
87+
constant(#collection)
88+
class(.item)
89+
class(.description) plain(What a cool item!)
90+
tag(%div)constant(#collection)
91+
tag(%div)class(.item)
92+
tag(%div)class(.description) plain(What a cool item!)
93+
94+
tag(%br/)
95+
tag(%meta)plain({)string<delimiter(')content(http-equiv)delimiter(')> operator(=)operator(>) string<delimiter(')content(Content-Type)delimiter(')>operator(,) symbol(:content) operator(=)operator(>) string<delimiter(')content(text/html)delimiter(')>plain(})tag(/)
96+
97+
tag(%br)
98+
tag(%meta)plain({)string<delimiter(')content(http-equiv)delimiter(')> operator(=)operator(>) string<delimiter(')content(Content-Type)delimiter(')>operator(,) symbol(:content) operator(=)operator(>) string<delimiter(')content(text/html)delimiter(')>plain(})
99+
100+
tag(%blockquote)plain(<)
101+
tag(%div)
102+
plain(Foo!)
103+
104+
tag(%img)
105+
tag(%img)plain(>)
106+
tag(%img)
107+
108+
tag(%p)plain(<= )string<delimiter(")content(Foo)char(\\n)content(Bar)delimiter(")>
109+
110+
tag(%img)
111+
tag(%pre)plain(><)
112+
plain(foo)
113+
plain(bar)
114+
tag(%img)
115+
116+
plain(-)comment(# file: app/views/users/show.haml)
117+
118+
tag(%div)plain([)instance_variable(@user)operator(,) symbol(:greeting)plain(])
119+
tag(%bar)plain([)integer(290)plain(])tag(/)
120+
plain(Hello!)
121+
122+
plain(-)comment(# file: app/views/users/show.haml)
123+
124+
tag(%div)plain([)instance_variable(@user)plain(])
125+
plain(Hello!)
126+
127+
tag(%peanutbutterjelly)
128+
comment(/ This is the peanutbutterjelly element)
129+
plain(I like sandwiches!)
130+
131+
comment(/)comment(
132+
%p This doesn't render...
133+
%div
134+
%h1 Because it's commented out!)
135+
136+
comment(/[if IE])
137+
tag(%a)plain({) symbol(:href) operator(=)operator(>) string<delimiter(')content(http://www.mozilla.com/en-US/firefox/)delimiter(')> plain(})
138+
tag(%h1) plain(Get Firefox)
139+
140+
tag(%p) plain(foo)
141+
plain(-)comment(# This is a comment)
142+
tag(%p) plain(bar)
143+
144+
tag(%p) plain(foo)
145+
comment(-#)comment(
146+
This won't be displayed
147+
Nor will this)
148+
tag(%p) plain(bar)
149+
150+
tag(%p)
151+
plain(= )operator([)string<delimiter(')content(hi)delimiter(')>operator(,) string<delimiter(')content(there)delimiter(')>operator(,) string<delimiter(')content(reader!)delimiter(')>operator(])operator(.)ident(join) string<delimiter(")content( )delimiter(")>
152+
plain(= )string<delimiter(")content(yo)delimiter(")>
153+
154+
plain(= )string<delimiter(')content(<script>alert("I)char(\\')content(m evil!"\);</script>)delimiter(')>
155+
156+
tag(%p)plain(= )string<delimiter(")content(hello)delimiter(")>
157+
158+
plain(= )ident(link_to_remote) string<delimiter(")content(Add to cart)delimiter(")>operator(,)
159+
symbol(:url) operator(=)operator(>) operator({) symbol(:action) operator(=)operator(>) string<delimiter(")content(add)delimiter(")>operator(,) symbol(:id) operator(=)operator(>) ident(product)operator(.)ident(id) operator(})operator(,)
160+
symbol(:update) operator(=)operator(>) operator({) symbol(:success) operator(=)operator(>) string<delimiter(")content(cart)delimiter(")>operator(,) symbol(:failure) operator(=)operator(>) string<delimiter(")content(error)delimiter(")> operator(})
161+
162+
plain(- )ident(foo) operator(=) string<delimiter(")content(hello)delimiter(")>
163+
plain(- )ident(foo) operator(<<) string<delimiter(")content( there)delimiter(")>
164+
plain(- )ident(foo) operator(<<) string<delimiter(")content( you!)delimiter(")>
165+
tag(%p)plain(= )ident(foo)
166+
167+
plain(- )ident(links) operator(=) operator({)symbol(:home) operator(=)operator(>) string<delimiter(")content(/)delimiter(")>operator(,)
168+
symbol(:docs) operator(=)operator(>) string<delimiter(")content(/docs)delimiter(")>operator(,)
169+
symbol(:about) operator(=)operator(>) string<delimiter(")content(/about)delimiter(")>operator(})
170+
171+
plain(- )operator(()integer(42)operator(...)integer(47)operator(\))operator(.)ident(each) keyword(do) operator(|)ident(i)plain(|)
172+
tag(%p)plain(= )ident(i)
173+
tag(%p) plain(See, I can count!)
174+
175+
tag(%p)
176+
plain(- )keyword(case) integer(2)
177+
plain(- )keyword(when) integer(1)
178+
plain(= )string<delimiter(")content(1!)delimiter(")>
179+
plain(- )keyword(when) integer(2)
180+
plain(= )string<delimiter(")content(2?)delimiter(")>
181+
plain(- )keyword(when) integer(3)
182+
plain(= )string<delimiter(")content(3.)delimiter(")>
183+
184+
plain(~ )string<delimiter(")content(Foo)char(\\n)content(<pre>Bar)char(\\n)content(Baz</pre>)delimiter(")>
185+
186+
plain(= )ident(find_and_preserve)operator(()string<delimiter(")content(Foo)char(\\n)content(<pre>Bar)char(\\n)content(Baz</pre>)delimiter(")>operator(\))
187+
188+
tag(%p) plain(This is #{h quality} cake!)
189+
190+
tag(%p)plain(= )string<delimiter(")content(This is the )inline<inline_delimiter(#{)ident(h) ident(quality)inline_delimiter(})>content( cake!)delimiter(")>
191+
192+
tag(%p)
193+
plain(Look at \\\\#{h word} lack of backslash: \\#{foo})
194+
plain(And yon presence thereof: \\{foo})
195+
196+
comment(:javascript)
197+
predefined($)operator(()ident(document)operator(\))operator(.)ident(ready)operator(()keyword(function)operator(()operator(\)) operator({)
198+
ident(alert)operator(()error(#)operator({)error(@)ident(message)operator(.)ident(to_json)operator(}\))operator(;)
199+
operator(}\))operator(;)
200+
201+
plain(&= )string<delimiter(")content(I like cheese & crackers)delimiter(")>
202+
203+
plain(& )string<content(I like )inline<inline_delimiter(#{)string<delimiter(")content(cheese & crackers)delimiter(")>inline_delimiter(})>>
204+
205+
plain(= )string<delimiter(")content(I feel <strong>!)delimiter(")>
206+
plain(!= )string<delimiter(")content(I feel <strong>!)delimiter(")>
207+
208+
plain(! )string<content(I feel )inline<inline_delimiter(#{)string<delimiter(")content(<strong>)delimiter(")>inline_delimiter(})>content(!)>
209+
210+
tag(%p)
211+
comment( :markdown)comment(
212+
Textile
213+
=======
214+
215+
Hello, *World*)
216+
217+
plain(- )ident(flavor) operator(=) string<delimiter(")content(raspberry)delimiter(")>
218+
constant(#content)
219+
comment( :textile)comment(
220+
I *really* prefer _#{h flavor}_ jam.)
221+
222+
comment(:plain)comment(
223+
Does not parse the filtered text. This is useful for large blocks of text without HTML tags, when you don’t want lines starting with . or - to be parsed.)
224+
225+
comment(:javascript)
226+
ident(Surrounds) ident(the) ident(filtered) ident(text) keyword(with) operator(<)ident(script)operator(>) ident(and) ident(CDATA) ident(tags)operator(.) ident(Useful) keyword(for) ident(including) ident(inline) ident(Javascript)operator(.)
227+
228+
comment(:css)comment(
229+
Surrounds the filtered text with <style> and CDATA tags. Useful for including inline CSS.)
230+
231+
comment(:cdata)comment(
232+
Surrounds the filtered text with CDATA tags.)
233+
234+
comment(:escaped)comment(
235+
Works the same as plain, but HTML-escapes the text before placing it in the document.)
236+
237+
comment(:ruby)
238+
constant(Parses) ident(the) ident(filtered) ident(text) ident(with) ident(the) ident(normal) constant(Ruby) ident(interpreter)operator(.) ident(All) ident(output) ident(sent) ident(to) global_variable($stdout)operator(,) ident(like) ident(with) ident(puts)operator(,) ident(is) ident(output) ident(into) ident(the) constant(Haml) ident(document)operator(.) ident(Not) ident(available) keyword(if) ident(the) symbol(:suppress_eval) ident(option) ident(is) ident(set) ident(to) predefined_constant(true)operator(.) ident(The) constant(Ruby) ident(code) ident(is) ident(evaluated) keyword(in) ident(the) ident(same) ident(context) ident(as) ident(the) constant(Haml) ident(template)operator(.)
239+
240+
comment(:preserve)comment(
241+
Inserts the filtered text into the template with whitespace preserved. preserved blocks of text aren’t indented, and newlines are replaced with the HTML escape code for newlines, to preserve nice-looking output. See also Whitespace Preservation.)
242+
243+
comment(:erb)comment(
244+
Parses the filtered text with ERb, like an RHTML template. Not available if the :suppress_eval option is set to true. Embedded Ruby code is evaluated in the same context as the Haml template.)
245+
246+
comment(:sass)comment(
247+
Parses the filtered text with Sass to produce CSS output.)
248+
249+
comment(:textile)comment(
250+
Parses the filtered text with Textile. Only works if RedCloth is installed.)
251+
252+
comment(:markdown)comment(
253+
Parses the filtered text with Markdown. Only works if RDiscount, RPeg-Markdown, Maruku, or BlueCloth are installed.)
254+
255+
comment(:maruku)comment(
256+
Parses the filtered text with Maruku, which has some non-standard extensions to Markdown.)
257+
258+
tag(%whoo)
259+
tag(%hoo)plain(= )ident(h)operator(() operator(|)
260+
string<delimiter(")content(I think this might get )delimiter(")> operator(+) operator(|)
261+
string<delimiter(")content(pretty long so I should )delimiter(")> operator(+) operator(|)
262+
string<delimiter(")content(probably make it )delimiter(")> operator(+) operator(|)
263+
string<delimiter(")content(multiline so it doesn't )delimiter(")> operator(+) operator(|)
264+
string<delimiter(")content(look awful.)delimiter(")>operator(\)) plain(|)
265+
tag(%p) plain(This is short.)
266+

0 commit comments

Comments
 (0)