4 it 'should be a triplet'
5 haml.version.should.match(/^\d+\.\d+\.\d+$/)
11 assertAs = function(name, type, options) {
12 var str = fixture(name + '.haml')
14 var html = haml.render(str, options).trim(),
15 expected = fixture(name + '.' + type).trim()
16 if (html === expected)
19 fail('got:\n' + html + '\n\nexpected:\n' + expected)
21 if (err instanceof haml.HamlError) {
24 fail('\n:' + err.stack + '\n')
28 assert = function(name, options) {
29 assertAs(name, 'html', options, 'CRLF', '\r\n')
31 assertXML = function(name, options) {
32 assertAs(name, 'xml', options, 'CRLF', '\r\n')
36 it 'should allow passing of a context object'
37 assert('context', { context: 'yay' })
40 it 'should allow passing of literals'
41 assert('literals', { locals: { user: 'tj' }})
44 it 'should not fail on trailing indents'
45 assert('trailing-indent')
48 it 'should add xml support via the "xml" option'
49 assertXML('feed', { xml: true })
52 it 'should support xml namespaces'
53 assertXML('namespace')
56 it 'should utilize "filename" option when an error is thrown'
57 try { assert('error', { filename: 'error.haml' }) }
59 err.message.should.eql '(error.haml):3 invalid indentation; got 3, when previous was 1'
63 it 'should default filename to "Haml" when an error is thrown'
64 try { assert('error') }
66 err.message.should.eql '(Haml):3 invalid indentation; got 3, when previous was 1'
70 it 'should bitch when "cache" is true without a filename given'
71 // -{ assert('tag.simple', { cache: true }) }.should.throw_error
74 it 'should pre-compiled and cache when "cache" is true'
75 assert('tag.simple', { cache: true, filename: 'tag.simple.haml' })
76 assert('tag.simple', { cache: true, filename: 'tag.simple.haml' })
79 it 'should support blank lines'
84 it 'should output a div with the given class'
88 it 'should work with several classes'
94 it 'should output a div with the given id'
100 it 'should work with no text or block'
104 it 'should work with text'
108 it 'should work with block text'
109 assert('tag.text.block')
112 it 'should work with blocks of text and tags'
113 assert('tag.text.block.complex')
116 it 'should work with many classes / ids / attrs'
117 assert('tag.complex')
120 it 'should allow empty tags'
125 describe '%tag.class'
126 it 'should output tag with a class'
130 it 'should work with several classes'
131 assert('tag.classes')
134 it 'should support self-closing tags'
135 assert('tag.self-close')
140 it 'should output the evaluated code'
144 it 'should not escape output'
145 assert('tag.code.no-escape')
150 it 'should escape the evaluated code'
155 describe '%namespace:tag'
156 it 'should output a tag with a namespace prefix'
157 assert('namespace.tag')
162 it 'should be mapped as html attributes'
166 it 'should escape values'
167 assert('tag.attrs.escape')
170 it 'should allow booleans'
171 assert('tag.attrs.bools')
176 it 'should default the doctype to 1.0 transitional'
182 it 'should output a specific doctype'
183 assert('doctype.xml')
186 it 'should be case-insensitive'
187 assert('doctype.xml.case')
192 it 'should work when nested downwards'
193 assert('nesting.simple')
196 it 'should work when blocks outdent'
197 assert('nesting.complex')
202 it 'should work with if statements'
206 it 'should work when nested'
207 assert('code.nested')
213 assert('code.each', { locals: { items: ['one', 'two', 'three'] }})
214 assert('code.each.non-enumerable', { locals: { items: null }})
217 it 'should iterate objects'
218 assert('code.each', { locals: { items: { 0: 'one', 1: 'two', 2: 'three' }}})
219 assert('code.each.index', { locals: { items: { 0: 'one', 1: 'two', 2: 'three' }}})
222 it 'should iterate with index'
223 assert('code.each.index', { locals: { items: ['one', 'two', 'three'] }})
228 it 'should output evaluation'
234 it 'should output evaluation while escaping html entities'
235 assert('code.escape')
239 describe '<literal></html>'
240 it 'should remain intact'
246 it 'should escape the character'
252 it 'should become a silent comment'
258 it 'should comment out tags'
259 assert('comment.tag')
262 it 'should comment out blocks'
263 assert('comment.block')
266 it 'should comment out text'
267 assert('comment.text')
270 it 'should work in blocks'
271 assert('comment.text.complex')
276 it 'should insert conditional comment blocks'
277 assert('comment.block.conditional')
283 it 'should ignore haml specific characters'
284 assert('filter.plain')
289 it 'should wrap with CDATA tags'
290 assert('filter.cdata')
293 it 'should retain whitespace'
294 assert('filter.cdata.whitespace')
298 describe 'javascript'
299 it 'should wrap with <script> and CDATA tags'
300 assert('filter.javascript')
307 assert('issue.#8', { locals: { items: ['foo', 'bar', 'baz'] }})
310 it '#10 Attributes should not need quotes'