haml 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/REVISION +1 -0
- data/Rakefile +6 -2
- data/VERSION +1 -1
- data/lib/haml.rb +12 -4
- data/lib/haml/buffer.rb +2 -2
- data/lib/haml/engine.rb +12 -5
- data/lib/haml/error.rb +4 -5
- data/lib/haml/exec.rb +4 -2
- data/lib/haml/helpers.rb +39 -22
- data/lib/haml/helpers/action_view_mods.rb +72 -35
- data/lib/haml/precompiler.rb +17 -26
- data/lib/haml/template.rb +11 -3
- data/lib/haml/template/patch.rb +1 -1
- data/lib/sass.rb +26 -3
- data/lib/sass/constant.rb +26 -57
- data/lib/sass/constant/literal.rb +1 -0
- data/lib/sass/constant/nil.rb +9 -0
- data/lib/sass/engine.rb +10 -4
- data/test/haml/engine_test.rb +20 -1
- data/test/haml/helper_test.rb +18 -2
- data/test/haml/html2haml_test.rb +1 -3
- data/test/haml/results/helpers.xhtml +2 -5
- data/test/haml/results/just_stuff.xhtml +0 -1
- data/test/haml/results/nuke_inner_whitespace.xhtml +6 -0
- data/test/haml/results/whitespace_handling.xhtml +1 -1
- data/test/haml/template_test.rb +29 -46
- data/test/haml/templates/helpers.haml +1 -1
- data/test/haml/templates/just_stuff.haml +0 -1
- data/test/haml/templates/nuke_inner_whitespace.haml +6 -0
- data/test/haml/templates/partials.haml +1 -1
- data/test/haml/templates/whitespace_handling.haml +10 -10
- data/test/sass/engine_test.rb +11 -5
- data/test/sass/plugin_test.rb +2 -6
- data/test/sass/results/constants.css +2 -0
- data/test/sass/templates/constants.sass +3 -0
- data/test/{haml/test_helper.rb → test_helper.rb} +4 -3
- metadata +102 -99
data/lib/haml/template.rb
CHANGED
@@ -36,8 +36,16 @@ if defined?(RAILS_ROOT)
|
|
36
36
|
# to not need updating.
|
37
37
|
rails_init_file = File.join(RAILS_ROOT, 'vendor', 'plugins', 'haml', 'init.rb')
|
38
38
|
haml_init_file = Haml.scope('init.rb')
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
begin
|
40
|
+
if File.exists?(rails_init_file)
|
41
|
+
require 'fileutils'
|
42
|
+
FileUtils.cp(haml_init_file, rails_init_file) unless FileUtils.cmp(rails_init_file, haml_init_file)
|
43
|
+
end
|
44
|
+
rescue SystemCallError
|
45
|
+
warn <<END
|
46
|
+
HAML WARNING:
|
47
|
+
#{rails_init_file} is out of date and couldn't be automatically updated.
|
48
|
+
Please run `haml --rails #{File.expand_path(RAILS_ROOT)}' to update it.
|
49
|
+
END
|
42
50
|
end
|
43
51
|
end
|
data/lib/haml/template/patch.rb
CHANGED
@@ -35,7 +35,7 @@ module ActionView
|
|
35
35
|
options[:filename] = file_name || 'compiled-template'
|
36
36
|
|
37
37
|
begin
|
38
|
-
Haml::Engine.new(template, options).def_method(CompiledTemplates, render_symbol, *
|
38
|
+
Haml::Engine.new(template, options).def_method(CompiledTemplates, render_symbol, *locals_keys)
|
39
39
|
rescue Exception => e
|
40
40
|
if logger
|
41
41
|
logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
|
data/lib/sass.rb
CHANGED
@@ -253,6 +253,22 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
|
|
253
253
|
# font-size: 30em;
|
254
254
|
# font-weight: bold; }
|
255
255
|
#
|
256
|
+
# === Rule Escaping
|
257
|
+
#
|
258
|
+
# In case, for whatever reason, you need to write a rule
|
259
|
+
# that begins with a Sass-meaningful character,
|
260
|
+
# you can escape it with a backslash (<tt>\</tt>).
|
261
|
+
# For example:
|
262
|
+
#
|
263
|
+
# #main
|
264
|
+
# \+div
|
265
|
+
# clear: both
|
266
|
+
#
|
267
|
+
# is compiled to:
|
268
|
+
#
|
269
|
+
# #main +div {
|
270
|
+
# clear: both; }
|
271
|
+
#
|
256
272
|
# == Constants
|
257
273
|
#
|
258
274
|
# Sass has support for setting document-wide constants.
|
@@ -760,9 +776,16 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
|
|
760
776
|
#
|
761
777
|
# == Sass Options
|
762
778
|
#
|
763
|
-
# Options can be set by setting the
|
764
|
-
#
|
765
|
-
#
|
779
|
+
# Options can be set by setting the <tt>Sass::Plugin.options</tt> hash
|
780
|
+
# in <tt>environment.rb</tt> in Rails...
|
781
|
+
#
|
782
|
+
# Sass::Plugin.options[:style] = :compact
|
783
|
+
#
|
784
|
+
# ...or by setting the <tt>Merb::Config[:sass]</tt> hash in <tt>init.rb</tt> in Merb...
|
785
|
+
#
|
786
|
+
# Merb::Config[:sass][:style] = :compact
|
787
|
+
#
|
788
|
+
# ...or by passing an options hash to Sass::Engine.new.
|
766
789
|
# Available options are:
|
767
790
|
#
|
768
791
|
# [<tt>:style</tt>] Sets the style of the CSS output.
|
data/lib/sass/constant.rb
CHANGED
@@ -119,17 +119,10 @@ module Sass
|
|
119
119
|
next
|
120
120
|
end
|
121
121
|
|
122
|
-
# Is this a constant?
|
123
|
-
if beginning_of_token && symbol == :const
|
124
|
-
beginning_of_token = true
|
125
|
-
to_return << :const
|
126
|
-
next
|
127
|
-
end
|
128
|
-
|
129
122
|
# Are we looking at an operator?
|
130
123
|
if symbol && (symbol != :mod || str.empty?)
|
131
124
|
str = reset_str.call
|
132
|
-
beginning_of_token =
|
125
|
+
beginning_of_token = symbol != :close
|
133
126
|
to_return << symbol
|
134
127
|
next
|
135
128
|
end
|
@@ -148,57 +141,30 @@ module Sass
|
|
148
141
|
to_return
|
149
142
|
end
|
150
143
|
|
151
|
-
def parenthesize(value)
|
152
|
-
parenthesize_helper(0, value, value.length)[0]
|
153
|
-
end
|
154
|
-
|
155
|
-
def parenthesize_helper(i, value, value_len, return_after_expr = false)
|
144
|
+
def parenthesize(value, return_after_expr = false)
|
156
145
|
to_return = []
|
157
|
-
|
158
|
-
token = value
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
to_return <<
|
166
|
-
|
167
|
-
if value
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
sub, i = parenthesize_helper(i + 2, value, value_len)
|
173
|
-
beginning = i
|
174
|
-
to_return << [:neg, sub]
|
175
|
-
elsif value[i + 1].is_a?(::Symbol)
|
176
|
-
to_return.push(*value[beginning...i])
|
177
|
-
sub, i = parenthesize_helper(i + 1, value, value_len, true)
|
178
|
-
beginning = i
|
179
|
-
to_return << [:neg, sub]
|
180
|
-
else
|
181
|
-
to_return.push(*value[beginning...i])
|
182
|
-
to_return << [:neg, value[i + 1]]
|
183
|
-
beginning = i = i + 2
|
184
|
-
end
|
185
|
-
return to_return[0], i if return_after_expr
|
186
|
-
elsif token == :const
|
187
|
-
raise Sass::SyntaxError.new("Unterminated constant.") if value[i + 1].nil?
|
188
|
-
raise Sass::SyntaxError.new("Invalid constant.") unless value[i + 1].is_a?(::String)
|
189
|
-
|
190
|
-
to_return.push(*value[beginning...i])
|
191
|
-
to_return << [:const, value[i + 1]]
|
192
|
-
beginning = i = i + 2
|
193
|
-
return to_return[0], i if return_after_expr
|
146
|
+
|
147
|
+
while (token = value.shift) && token != :close
|
148
|
+
case token
|
149
|
+
when :open
|
150
|
+
to_return << parenthesize(value)
|
151
|
+
when :neg
|
152
|
+
# This is never actually reached, but we'll leave it in just in case.
|
153
|
+
raise Sass::SyntaxError.new("Unterminated unary minus.") if value.first.nil?
|
154
|
+
to_return << [:neg, parenthesize(value, true)]
|
155
|
+
when :const
|
156
|
+
raise Sass::SyntaxError.new("Unterminated constant.") if value.first.nil?
|
157
|
+
raise Sass::SyntaxError.new("Invalid constant.") unless value.first.is_a?(::String)
|
158
|
+
|
159
|
+
to_return << [:const, value.first]
|
160
|
+
value.shift
|
194
161
|
else
|
195
|
-
|
162
|
+
to_return << token
|
196
163
|
end
|
197
164
|
|
198
|
-
|
165
|
+
return to_return.first if return_after_expr
|
199
166
|
end
|
200
|
-
to_return
|
201
|
-
return to_return, i + 1
|
167
|
+
return to_return
|
202
168
|
end
|
203
169
|
|
204
170
|
#--
|
@@ -207,7 +173,10 @@ module Sass
|
|
207
173
|
#++
|
208
174
|
def operationalize(value, constants)
|
209
175
|
value = [value] unless value.is_a?(Array)
|
210
|
-
|
176
|
+
case value.length
|
177
|
+
when 0
|
178
|
+
Sass::Constant::Nil.new
|
179
|
+
when 1
|
211
180
|
value = value[0]
|
212
181
|
if value.is_a? Array
|
213
182
|
operationalize(value, constants)
|
@@ -216,7 +185,7 @@ module Sass
|
|
216
185
|
else
|
217
186
|
Literal.parse(value)
|
218
187
|
end
|
219
|
-
|
188
|
+
when 2
|
220
189
|
if value[0] == :neg
|
221
190
|
Operation.new(Sass::Constant::Number.new('0'), operationalize(value[1], constants), :minus)
|
222
191
|
elsif value[0] == :const
|
@@ -224,7 +193,7 @@ module Sass
|
|
224
193
|
else
|
225
194
|
raise SyntaxError.new("Constant arithmetic error")
|
226
195
|
end
|
227
|
-
|
196
|
+
when 3
|
228
197
|
Operation.new(operationalize(value[0], constants), operationalize(value[2], constants), value[1])
|
229
198
|
else
|
230
199
|
if SECOND_ORDER.include?(value[1]) && FIRST_ORDER.include?(value[3])
|
@@ -4,6 +4,7 @@ module Sass::Constant; class Literal; end; end; # :nodoc:
|
|
4
4
|
require 'sass/constant/string'
|
5
5
|
require 'sass/constant/number'
|
6
6
|
require 'sass/constant/color'
|
7
|
+
require 'sass/constant/nil'
|
7
8
|
|
8
9
|
class Sass::Constant::Literal # :nodoc:
|
9
10
|
# The regular expression matching numbers.
|
data/lib/sass/engine.rb
CHANGED
@@ -134,7 +134,7 @@ module Sass
|
|
134
134
|
# and computes the tabulation of the line.
|
135
135
|
def split_lines
|
136
136
|
@line = 0
|
137
|
-
old_tabs =
|
137
|
+
old_tabs = nil
|
138
138
|
@template.each_with_index do |line, index|
|
139
139
|
@line += 1
|
140
140
|
|
@@ -145,14 +145,16 @@ module Sass
|
|
145
145
|
end
|
146
146
|
|
147
147
|
if tabs # if line isn't blank
|
148
|
-
|
148
|
+
raise SyntaxError.new("Indenting at the beginning of the document is illegal.", @line) if old_tabs.nil? && tabs > 0
|
149
|
+
|
150
|
+
if old_tabs && tabs - old_tabs > 1
|
149
151
|
raise SyntaxError.new("#{tabs * 2} spaces were used for indentation. Sass must be indented using two spaces.", @line)
|
150
152
|
end
|
151
153
|
@lines << [line.strip, tabs]
|
152
154
|
|
153
155
|
old_tabs = tabs
|
154
156
|
else
|
155
|
-
@lines << ['//', old_tabs]
|
157
|
+
@lines << ['//', old_tabs || 0]
|
156
158
|
end
|
157
159
|
end
|
158
160
|
|
@@ -287,7 +289,11 @@ END
|
|
287
289
|
when MIXIN_DEFINITION_CHAR
|
288
290
|
parse_mixin_definition(line)
|
289
291
|
when MIXIN_INCLUDE_CHAR
|
290
|
-
|
292
|
+
if line[1].nil? || line[1] == ?\s
|
293
|
+
Tree::RuleNode.new(line, @options[:style])
|
294
|
+
else
|
295
|
+
parse_mixin_include(line)
|
296
|
+
end
|
291
297
|
else
|
292
298
|
if line =~ ATTRIBUTE_ALTERNATE_MATCHER
|
293
299
|
parse_attribute(line, ATTRIBUTE_ALTERNATE)
|
data/test/haml/engine_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require File.dirname(__FILE__) + '
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
3
3
|
|
4
4
|
class EngineTest < Test::Unit::TestCase
|
5
5
|
# A map of erroneous Sass documents to the error messages they should produce.
|
@@ -32,11 +32,23 @@ END
|
|
32
32
|
".= a" => "Illegal element: classes and ids must have values.",
|
33
33
|
"%p..a" => "Illegal element: classes and ids must have values.",
|
34
34
|
"%a/ b" => "Self-closing tags can't have content.",
|
35
|
+
" %p foo" => "Indenting at the beginning of the document is illegal.",
|
36
|
+
" %p foo" => "Indenting at the beginning of the document is illegal.",
|
37
|
+
" \n\t\n %p foo" => ["Indenting at the beginning of the document is illegal.", 3],
|
35
38
|
|
36
39
|
# Regression tests
|
37
40
|
"- raise 'foo'\n\n\n\nbar" => ["foo", 1],
|
38
41
|
"= 'foo'\n-raise 'foo'" => ["foo", 2],
|
39
42
|
"\n\n\n- raise 'foo'" => ["foo", 4],
|
43
|
+
"foo\n\n\n bar" => ["Illegal nesting: nesting within plain text is illegal.", 4],
|
44
|
+
"%p/\n\n bar" => ["Illegal nesting: nesting within a self-closing tag is illegal.", 3],
|
45
|
+
"%p foo\n\n bar" => ["Illegal nesting: content can't be both given on the same line as %p and nested within it.", 3],
|
46
|
+
"/ foo\n\n bar" => ["Illegal nesting: nesting within a tag that already has content is illegal.", 3],
|
47
|
+
"!!!\n\n bar" => ["Illegal nesting: nesting within a header command is illegal.", 3],
|
48
|
+
"foo\n\n\n\tbar" => [<<END.strip, 4],
|
49
|
+
A tab character was used for indentation. Haml must be indented using two spaces.
|
50
|
+
Are you sure you have soft tabs enabled in your editor?
|
51
|
+
END
|
40
52
|
}
|
41
53
|
|
42
54
|
User = Struct.new('User', :id)
|
@@ -541,6 +553,13 @@ END
|
|
541
553
|
render("%p= 's' * 75", :ugly => true))
|
542
554
|
end
|
543
555
|
|
556
|
+
def test_auto_preserve_unless_ugly
|
557
|
+
assert_equal("<pre>foo
bar</pre>\n", render('%pre="foo\nbar"'))
|
558
|
+
assert_equal("<pre>foo\nbar</pre>\n", render("%pre\n foo\n bar"))
|
559
|
+
assert_equal("<pre>foo\nbar</pre>\n", render('%pre="foo\nbar"', :ugly => true))
|
560
|
+
assert_equal("<pre>foo\nbar</pre>\n", render("%pre\n foo\n bar", :ugly => true))
|
561
|
+
end
|
562
|
+
|
544
563
|
def test_xhtml_output_option
|
545
564
|
assert_equal "<p>\n <br />\n</p>\n", render("%p\n %br", :format => :xhtml)
|
546
565
|
assert_equal "<a />\n", render("%a/", :format => :xhtml)
|
data/test/haml/helper_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require File.dirname(__FILE__) + '
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
3
3
|
require 'haml/template'
|
4
4
|
|
5
5
|
class HelperTest < Test::Unit::TestCase
|
@@ -105,7 +105,23 @@ class HelperTest < Test::Unit::TestCase
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_haml_tag_non_autoclosed_tags_arent_closed
|
108
|
-
assert_equal("<p
|
108
|
+
assert_equal("<p></p>\n", render("- haml_tag :p"))
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_haml_tag_renders_text_on_a_single_line
|
112
|
+
assert_equal("<p>#{'a' * 100}</p>\n", render("- haml_tag :p, 'a' * 100"))
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_haml_tag_raises_error_for_multiple_content
|
116
|
+
assert_raise(Haml::Error) { render("- haml_tag :p, 'foo' do\n bar") }
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_haml_tag_flags
|
120
|
+
assert_equal("<p />\n", render("- haml_tag :p, :/"))
|
121
|
+
assert_equal("<p>kumquat</p>\n", render("- haml_tag :p, :< do\n kumquat"))
|
122
|
+
|
123
|
+
assert_raise(Haml::Error) { render("- haml_tag :p, 'foo', :/") }
|
124
|
+
assert_raise(Haml::Error) { render("- haml_tag :p, :/ do\n foo") }
|
109
125
|
end
|
110
126
|
|
111
127
|
def test_is_haml
|
data/test/haml/html2haml_test.rb
CHANGED
@@ -75,7 +75,7 @@
|
|
75
75
|
</p>
|
76
76
|
<pre> ___
 ,o88888
 ,o8888888'
 ,:o:o:oooo. ,8O88Pd8888"
 ,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
 ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
 , ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
 , ..:.::o:ooOoOO8O888O8O,COCOO"
 , . ..:.::o:ooOoOOOO8OOOOCOCO"
 . ..:.::o:ooOoOoOO8O8OCCCC"o
 . ..:.::o:ooooOoCoCCC"o:o
 . ..:.::o:o:,cooooCo"oo:o:
 ` . . ..:.:cocoooo"'o:o:::'
 .` . ..::ccccoc"'o:o:o:::'
 :.:. ,c:cccc"':.:.:.:.:.'
 ..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/
 ...:.'.:.::::"' . . . . .'
 .. . ....:."' ` . . . ''
 . . . ...."'
 .. . ."' -hrr-
 .


 It's a planet!
%strong This shouldn't be bold!</pre>
|
77
77
|
<strong>This should!</strong>
|
78
|
-
<textarea> ___ ___ ___ ___ 
 /\__\ /\ \ /\__\ /\__\
 /:/ / /::\ \ /::| | /:/ /
 /:/__/ /:/\:\ \ /:|:| | /:/ / 
 /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / 
 /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ 
 \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ 
 \::/ / \::/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\__\
 \/__/ \/__/ \/__/ \/__/

|
78
|
+
<textarea> ___ ___ ___ ___ 
 /\__\ /\ \ /\__\ /\__\
 /:/ / /::\ \ /::| | /:/ /
 /:/__/ /:/\:\ \ /:|:| | /:/ / 
 /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / 
 /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ 
 \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ 
 \::/ / \::/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\__\
 \/__/ \/__/ \/__/ \/__/
 
 Many
 thanks
 to
 http://www.network-science.de/ascii/
|
79
79
|
<strong>indeed!</strong></textarea>
|
80
80
|
</div>
|
81
81
|
<div class='foo'>
|
data/test/haml/template_test.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require File.dirname(__FILE__) + '
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
3
3
|
require 'haml/template'
|
4
4
|
require File.dirname(__FILE__) + '/mocks/article'
|
5
5
|
|
6
|
-
|
7
6
|
module Haml::Filters::Test
|
8
7
|
include Haml::Filters::Base
|
9
8
|
|
@@ -12,14 +11,21 @@ module Haml::Filters::Test
|
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
14
|
+
module Haml::Helpers
|
15
|
+
def test_partial(name, locals = {})
|
16
|
+
Haml::Engine.new(File.read(File.join(TemplateTest::TEMPLATE_PATH, "_#{name}.haml"))).render(self, locals)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
15
20
|
class TemplateTest < Test::Unit::TestCase
|
16
|
-
|
21
|
+
TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates")
|
22
|
+
TEMPLATES = %w{ very_basic standard helpers
|
17
23
|
whitespace_handling original_engine list helpful
|
18
24
|
silent_script tag_parsing just_stuff partials
|
19
25
|
filters nuke_outer_whitespace nuke_inner_whitespace }
|
20
26
|
|
21
27
|
def setup
|
22
|
-
@base = ActionView::Base.new(
|
28
|
+
@base = ActionView::Base.new(TEMPLATE_PATH, 'article' => Article.new, 'foo' => 'value one')
|
23
29
|
@base.send(:evaluate_assigns)
|
24
30
|
|
25
31
|
# This is used by form_for.
|
@@ -39,20 +45,16 @@ class TemplateTest < Test::Unit::TestCase
|
|
39
45
|
|
40
46
|
def assert_renders_correctly(name, &render_method)
|
41
47
|
render_method ||= proc { |name| @base.render(name) }
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
48
|
+
|
49
|
+
load_result(name).split("\n").zip(render_method[name].split("\n")).each_with_index do |pair, line|
|
50
|
+
message = "template: #{name}\nline: #{line}"
|
51
|
+
assert_equal(pair.first, pair.last, message)
|
47
52
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
else
|
54
|
-
raise e
|
55
|
-
end
|
53
|
+
rescue ActionView::TemplateError => e
|
54
|
+
if e.message =~ /Can't run [\w:]+ filter; required (one of|file) ((?:'\w+'(?: or )?)+)(, but none were found| not found)/
|
55
|
+
puts "\nCouldn't require #{$2}; skipping a test."
|
56
|
+
else
|
57
|
+
raise e
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
@@ -60,30 +62,24 @@ class TemplateTest < Test::Unit::TestCase
|
|
60
62
|
assert_equal('', render(''))
|
61
63
|
end
|
62
64
|
|
63
|
-
|
64
|
-
|
65
|
+
TEMPLATES.each do |template|
|
66
|
+
define_method "test_template_should_render_correctly [template: #{template}] " do
|
65
67
|
assert_renders_correctly template
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
69
71
|
def test_templates_should_render_correctly_with_render_proc
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
engine.render_proc(@base).call
|
74
|
-
end
|
72
|
+
assert_renders_correctly("standard") do |name|
|
73
|
+
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"))
|
74
|
+
engine.render_proc(@base).call
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def test_templates_should_render_correctly_with_def_method
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"))
|
84
|
-
engine.def_method(@base, method)
|
85
|
-
@base.send(method)
|
86
|
-
end
|
79
|
+
assert_renders_correctly("standard") do |name|
|
80
|
+
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"))
|
81
|
+
engine.def_method(@base, "render_standard")
|
82
|
+
@base.render_standard
|
87
83
|
end
|
88
84
|
end
|
89
85
|
|
@@ -115,19 +111,6 @@ class TemplateTest < Test::Unit::TestCase
|
|
115
111
|
assert_equal("2\n", render("= 1+1"))
|
116
112
|
end
|
117
113
|
|
118
|
-
def test_rhtml_still_renders
|
119
|
-
# Make sure it renders normally
|
120
|
-
res = @base.render("../rhtml/standard")
|
121
|
-
assert !(res.nil? || res.empty?)
|
122
|
-
|
123
|
-
# Register Haml stuff in @base...
|
124
|
-
@base.render("standard")
|
125
|
-
|
126
|
-
# Does it still render?
|
127
|
-
res = @base.render("../rhtml/standard")
|
128
|
-
assert !(res.nil? || res.empty?)
|
129
|
-
end
|
130
|
-
|
131
114
|
def test_haml_options
|
132
115
|
Haml::Template.options = { :suppress_eval => true }
|
133
116
|
assert_equal({ :suppress_eval => true }, Haml::Template.options)
|