tilt 2.0.9 → 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tilt.rb +1 -1
  3. data/lib/tilt/template.rb +7 -12
  4. metadata +3 -104
  5. data/CHANGELOG.md +0 -132
  6. data/Gemfile +0 -70
  7. data/HACKING +0 -16
  8. data/README.md +0 -233
  9. data/Rakefile +0 -106
  10. data/docs/TEMPLATES.md +0 -555
  11. data/docs/common.css +0 -14
  12. data/man/index.txt +0 -2
  13. data/man/tilt.1.ronn +0 -59
  14. data/test/markaby/locals.mab +0 -1
  15. data/test/markaby/markaby.mab +0 -1
  16. data/test/markaby/markaby_other_static.mab +0 -1
  17. data/test/markaby/render_twice.mab +0 -1
  18. data/test/markaby/scope.mab +0 -1
  19. data/test/markaby/yielding.mab +0 -2
  20. data/test/mytemplate.rb +0 -2
  21. data/test/test_helper.rb +0 -64
  22. data/test/tilt_asciidoctor_test.rb +0 -50
  23. data/test/tilt_babeltemplate.rb +0 -33
  24. data/test/tilt_blueclothtemplate_test.rb +0 -33
  25. data/test/tilt_buildertemplate_test.rb +0 -72
  26. data/test/tilt_cache_test.rb +0 -43
  27. data/test/tilt_coffeescripttemplate_test.rb +0 -141
  28. data/test/tilt_commonmarkertemplate_test.rb +0 -28
  29. data/test/tilt_compilesite_test.rb +0 -51
  30. data/test/tilt_creoletemplate_test.rb +0 -24
  31. data/test/tilt_csv_test.rb +0 -77
  32. data/test/tilt_erbtemplate_test.rb +0 -239
  33. data/test/tilt_erubistemplate_test.rb +0 -151
  34. data/test/tilt_erubitemplate_test.rb +0 -158
  35. data/test/tilt_etannitemplate_test.rb +0 -174
  36. data/test/tilt_hamltemplate_test.rb +0 -166
  37. data/test/tilt_kramdown_test.rb +0 -20
  38. data/test/tilt_lesstemplate_test.less +0 -1
  39. data/test/tilt_lesstemplate_test.rb +0 -42
  40. data/test/tilt_liquidtemplate_test.rb +0 -87
  41. data/test/tilt_livescripttemplate_test.rb +0 -37
  42. data/test/tilt_mapping_test.rb +0 -232
  43. data/test/tilt_markaby_test.rb +0 -88
  44. data/test/tilt_markdown_test.rb +0 -186
  45. data/test/tilt_marukutemplate_test.rb +0 -36
  46. data/test/tilt_metadata_test.rb +0 -42
  47. data/test/tilt_nokogiritemplate_test.rb +0 -87
  48. data/test/tilt_pandoctemplate_test.rb +0 -67
  49. data/test/tilt_prawntemplate.prawn +0 -1
  50. data/test/tilt_prawntemplate_test.rb +0 -75
  51. data/test/tilt_radiustemplate_test.rb +0 -75
  52. data/test/tilt_rdiscounttemplate_test.rb +0 -43
  53. data/test/tilt_rdoctemplate_test.rb +0 -29
  54. data/test/tilt_redcarpettemplate_test.rb +0 -54
  55. data/test/tilt_redclothtemplate_test.rb +0 -36
  56. data/test/tilt_rstpandoctemplate_test.rb +0 -32
  57. data/test/tilt_sasstemplate_test.rb +0 -42
  58. data/test/tilt_sigil_test.rb +0 -41
  59. data/test/tilt_stringtemplate_test.rb +0 -171
  60. data/test/tilt_template_test.rb +0 -314
  61. data/test/tilt_test.rb +0 -60
  62. data/test/tilt_typescript_test.rb +0 -38
  63. data/test/tilt_wikiclothtemplate_test.rb +0 -32
  64. data/test/tilt_yajltemplate_test.rb +0 -101
  65. data/tilt.gemspec +0 -130
@@ -1,28 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- begin
5
- require 'tilt/commonmarker'
6
-
7
- class CommonMarkerTemplateTest < Minitest::Test
8
- test "preparing and evaluating templates on #render" do
9
- template = Tilt::CommonMarkerTemplate.new { |t| "# Hello World!" }
10
- assert_equal "<h1>Hello World!</h1>\n", template.render
11
- end
12
-
13
- test "can be rendered more than once" do
14
- template = Tilt::CommonMarkerTemplate.new { |t| "# Hello World!" }
15
- 3.times { assert_equal "<h1>Hello World!</h1>\n", template.render }
16
- end
17
-
18
- test "smartypants when :smartypants is set" do
19
- template = Tilt::CommonMarkerTemplate.new(:smartypants => true) do |t|
20
- "OKAY -- 'Smarty Pants'"
21
- end
22
- assert_match('<p>OKAY – ‘Smarty Pants’</p>', template.render)
23
- end
24
-
25
- end
26
- rescue LoadError
27
- warn "Tilt::CommonMarkerTemplate (disabled)"
28
- end
@@ -1,51 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
- require 'thread'
4
-
5
- class CompileSiteTest < Minitest::Test
6
- def setup
7
- GC.start
8
- end
9
-
10
- class CompilingTemplate < Tilt::Template
11
- def prepare
12
- end
13
-
14
- def precompiled_template(locals)
15
- @data.inspect
16
- end
17
- end
18
-
19
- class Scope
20
- end
21
-
22
- test "compiling template source to a method" do
23
- template = CompilingTemplate.new { |t| "Hello World!" }
24
- template.render(Scope.new)
25
- method = template.send(:compiled_method, [])
26
- assert_kind_of UnboundMethod, method
27
- end
28
-
29
- # This test attempts to surface issues with compiling templates from
30
- # multiple threads.
31
- test "using compiled templates from multiple threads" do
32
- template = CompilingTemplate.new { 'template' }
33
- main_thread = Thread.current
34
- 10.times do |i|
35
- threads =
36
- (1..50).map do |j|
37
- Thread.new {
38
- begin
39
- locals = { "local#{i}" => 'value' }
40
- res = template.render(self, locals)
41
- thread_id = Thread.current.object_id
42
- res = template.render(self, "local#{thread_id.abs.to_s}" => 'value')
43
- rescue => boom
44
- main_thread.raise(boom)
45
- end
46
- }
47
- end
48
- threads.each { |t| t.join }
49
- end
50
- end
51
- end
@@ -1,24 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- begin
5
- require 'tilt/creole'
6
-
7
- class CreoleTemplateTest < Minitest::Test
8
- test "is registered for '.creole' files" do
9
- assert_equal Tilt::CreoleTemplate, Tilt['test.creole']
10
- end
11
-
12
- test "compiles and evaluates the template on #render" do
13
- template = Tilt::CreoleTemplate.new { |t| "= Hello World!" }
14
- assert_equal "<h1>Hello World!</h1>", template.render
15
- end
16
-
17
- test "can be rendered more than once" do
18
- template = Tilt::CreoleTemplate.new { |t| "= Hello World!" }
19
- 3.times { assert_equal "<h1>Hello World!</h1>", template.render }
20
- end
21
- end
22
- rescue LoadError
23
- warn "Tilt::CreoleTemplate (disabled)"
24
- end
@@ -1,77 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- begin
5
- require 'tilt/csv'
6
-
7
- class CSVTemplateTest < Minitest::Test
8
-
9
- test "registered for '.rcsv' files" do
10
- assert_equal Tilt::CSVTemplate, Tilt['rcsv']
11
- end
12
-
13
- test "compiles and evaluates the template on #render" do
14
- template = Tilt::CSVTemplate.new { "csv << ['hello', 'world']" }
15
- assert_equal "hello,world\n", template.render
16
- end
17
-
18
- test "can be rendered more than once" do
19
- template = Tilt::CSVTemplate.new { "csv << [1,2,3]" }
20
- 3.times { assert_equal "1,2,3\n", template.render }
21
- end
22
-
23
- test "can pass locals" do
24
- template = Tilt::CSVTemplate.new { 'csv << [1, name]' }
25
- assert_equal "1,Joe\n", template.render(Object.new, :name => 'Joe')
26
- end
27
-
28
- test "evaluating in an object scope" do
29
- template = Tilt::CSVTemplate.new { 'csv << [1, @name]' }
30
- scope = Object.new
31
- scope.instance_variable_set :@name, 'Joe'
32
- assert_equal "1,Joe\n", template.render(scope)
33
- end
34
-
35
- test "backtrace file and line reporting" do
36
- data = File.read(__FILE__).split("\n__END__\n").last
37
- template = Tilt::CSVTemplate.new('test.csv') { data }
38
- begin
39
- template.render
40
- fail 'should have raised an exception'
41
- rescue => boom
42
- assert_kind_of NameError, boom
43
- line = boom.backtrace.grep(/^test\.csv:/).first
44
- assert line, "Backtrace didn't contain test.csv"
45
- _file, line, _meth = line.split(":")
46
- assert_equal '4', line
47
- end
48
- end
49
-
50
- test "passing options to engine" do
51
- template = Tilt::CSVTemplate.new(:col_sep => '|') { 'csv << [1,2,3]' }
52
- assert_equal "1|2|3\n", template.render
53
- end
54
-
55
- test "outvar option" do
56
- outvar = '@_output'
57
- scope = Object.new
58
- template = Tilt::CSVTemplate.new(:outvar => outvar) { 'csv << [1,2,3]' }
59
- output = template.render(scope)
60
- assert_equal output, scope.instance_variable_get(outvar.to_sym)
61
- end
62
- end
63
-
64
- rescue LoadError
65
- warn "Tilt::CSVTemplate (disabled) please install 'fastercsv' if using ruby 1.8.x"
66
- end
67
-
68
-
69
- __END__
70
- # header
71
- csv << ['Type', 'Age']
72
-
73
- raise NameError
74
-
75
- # rows
76
- csv << ['Frog', 2]
77
- csv << ['Cat', 5]
@@ -1,239 +0,0 @@
1
- # coding: utf-8
2
- require 'test_helper'
3
- require 'tilt'
4
- require 'tilt/erb'
5
- require 'tempfile'
6
-
7
- class ERBTemplateTest < Minitest::Test
8
- test "registered for '.erb' files" do
9
- assert_includes Tilt.lazy_map['erb'], ['Tilt::ERBTemplate', 'tilt/erb']
10
- end
11
-
12
- test "registered for '.rhtml' files" do
13
- assert_includes Tilt.lazy_map['rhtml'], ['Tilt::ERBTemplate', 'tilt/erb']
14
- end
15
-
16
- test "loading and evaluating templates on #render" do
17
- template = Tilt::ERBTemplate.new { |t| "Hello World!" }
18
- assert_equal "Hello World!", template.render
19
- end
20
-
21
- test "can be rendered more than once" do
22
- template = Tilt::ERBTemplate.new { |t| "Hello World!" }
23
- 3.times { assert_equal "Hello World!", template.render }
24
- end
25
-
26
- test "passing locals" do
27
- template = Tilt::ERBTemplate.new { 'Hey <%= name %>!' }
28
- assert_equal "Hey Joe!", template.render(Object.new, :name => 'Joe')
29
- end
30
-
31
- test "evaluating in an object scope" do
32
- template = Tilt::ERBTemplate.new { 'Hey <%= @name %>!' }
33
- scope = Object.new
34
- scope.instance_variable_set :@name, 'Joe'
35
- assert_equal "Hey Joe!", template.render(scope)
36
- end
37
-
38
- class MockOutputVariableScope
39
- attr_accessor :exposed_buffer
40
- end
41
-
42
- test "exposing the buffer to the template by default" do
43
- begin
44
- Tilt::ERBTemplate.default_output_variable = '@_out_buf'
45
- template = Tilt::ERBTemplate.new { '<% self.exposed_buffer = @_out_buf %>hey' }
46
- scope = MockOutputVariableScope.new
47
- template.render(scope)
48
- refute_nil scope.exposed_buffer
49
- assert_equal scope.exposed_buffer, 'hey'
50
- ensure
51
- Tilt::ERBTemplate.default_output_variable = '_erbout'
52
- end
53
- end
54
-
55
- test "passing a block for yield" do
56
- template = Tilt::ERBTemplate.new { 'Hey <%= yield %>!' }
57
- assert_equal "Hey Joe!", template.render { 'Joe' }
58
- end
59
-
60
- test "backtrace file and line reporting without locals" do
61
- data = File.read(__FILE__).split("\n__END__\n").last
62
- fail unless data[0] == ?<
63
- template = Tilt::ERBTemplate.new('test.erb', 11) { data }
64
- begin
65
- template.render
66
- fail 'should have raised an exception'
67
- rescue => boom
68
- assert_kind_of NameError, boom
69
- line = boom.backtrace.grep(/^test\.erb:/).first
70
- assert line, "Backtrace didn't contain test.erb"
71
- _file, line, _meth = line.split(":")
72
- assert_equal '13', line
73
- end
74
- end
75
-
76
- test "backtrace file and line reporting with locals" do
77
- data = File.read(__FILE__).split("\n__END__\n").last
78
- fail unless data[0] == ?<
79
- template = Tilt::ERBTemplate.new('test.erb', 1) { data }
80
- begin
81
- template.render(nil, :name => 'Joe', :foo => 'bar')
82
- fail 'should have raised an exception'
83
- rescue => boom
84
- assert_kind_of RuntimeError, boom
85
- line = boom.backtrace.first
86
- file, line, _meth = line.split(":")
87
- assert_equal 'test.erb', file
88
- assert_equal '6', line
89
- end
90
- end
91
-
92
- test "explicit disabling of trim mode" do
93
- template = Tilt::ERBTemplate.new('test.erb', 1, :trim => false) { "\n<%= 1 + 1 %>\n" }
94
- assert_equal "\n2\n", template.render
95
- end
96
-
97
- test "default stripping trim mode" do
98
- template = Tilt::ERBTemplate.new('test.erb', 1) { "\n<%= 1 + 1 %>\n" }
99
- assert_equal "\n2", template.render
100
- end
101
-
102
- test "stripping trim mode" do
103
- template = Tilt::ERBTemplate.new('test.erb', 1, :trim => '-') { "\n<%= 1 + 1 -%>\n" }
104
- assert_equal "\n2", template.render
105
- end
106
-
107
- test "shorthand whole line syntax trim mode" do
108
- template = Tilt::ERBTemplate.new('test.erb', :trim => '%') { "\n% if true\nhello\n%end\n" }
109
- assert_equal "\nhello\n", template.render
110
- end
111
-
112
- test "using an instance variable as the outvar" do
113
- template = Tilt::ERBTemplate.new(nil, :outvar => '@buf') { "<%= 1 + 1 %>" }
114
- scope = Object.new
115
- scope.instance_variable_set(:@buf, 'original value')
116
- assert_equal '2', template.render(scope)
117
- assert_equal 'original value', scope.instance_variable_get(:@buf)
118
- end
119
- end
120
-
121
- class CompiledERBTemplateTest < Minitest::Test
122
- def teardown
123
- GC.start
124
- end
125
-
126
- class Scope
127
- end
128
-
129
- test "compiling template source to a method" do
130
- template = Tilt::ERBTemplate.new { |t| "Hello World!" }
131
- template.render(Scope.new)
132
- method = template.send(:compiled_method, [])
133
- assert_kind_of UnboundMethod, method
134
- end
135
-
136
- test "loading and evaluating templates on #render" do
137
- template = Tilt::ERBTemplate.new { |t| "Hello World!" }
138
- assert_equal "Hello World!", template.render(Scope.new)
139
- assert_equal "Hello World!", template.render(Scope.new)
140
- end
141
-
142
- test "passing locals" do
143
- template = Tilt::ERBTemplate.new { 'Hey <%= name %>!' }
144
- assert_equal "Hey Joe!", template.render(Scope.new, :name => 'Joe')
145
- end
146
-
147
- test "evaluating in an object scope" do
148
- template = Tilt::ERBTemplate.new { 'Hey <%= @name %>!' }
149
- scope = Scope.new
150
- scope.instance_variable_set :@name, 'Joe'
151
- assert_equal "Hey Joe!", template.render(scope)
152
- scope.instance_variable_set :@name, 'Jane'
153
- assert_equal "Hey Jane!", template.render(scope)
154
- end
155
-
156
- test "passing a block for yield" do
157
- template = Tilt::ERBTemplate.new { 'Hey <%= yield %>!' }
158
- assert_equal "Hey Joe!", template.render(Scope.new) { 'Joe' }
159
- assert_equal "Hey Jane!", template.render(Scope.new) { 'Jane' }
160
- end
161
-
162
- test "backtrace file and line reporting without locals" do
163
- data = File.read(__FILE__).split("\n__END__\n").last
164
- fail unless data[0] == ?<
165
- template = Tilt::ERBTemplate.new('test.erb', 11) { data }
166
- begin
167
- template.render(Scope.new)
168
- fail 'should have raised an exception'
169
- rescue => boom
170
- assert_kind_of NameError, boom
171
- line = boom.backtrace.grep(/^test\.erb:/).first
172
- assert line, "Backtrace didn't contain test.erb"
173
- _file, line, _meth = line.split(":")
174
- assert_equal '13', line
175
- end
176
- end
177
-
178
- test "backtrace file and line reporting with locals" do
179
- data = File.read(__FILE__).split("\n__END__\n").last
180
- fail unless data[0] == ?<
181
- template = Tilt::ERBTemplate.new('test.erb') { data }
182
- begin
183
- template.render(Scope.new, :name => 'Joe', :foo => 'bar')
184
- fail 'should have raised an exception'
185
- rescue => boom
186
- assert_kind_of RuntimeError, boom
187
- line = boom.backtrace.first
188
- file, line, _meth = line.split(":")
189
- assert_equal 'test.erb', file
190
- assert_equal '6', line
191
- end
192
- end
193
-
194
- test "default stripping trim mode" do
195
- template = Tilt::ERBTemplate.new('test.erb') { "\n<%= 1 + 1 %>\n" }
196
- assert_equal "\n2", template.render(Scope.new)
197
- end
198
-
199
- test "stripping trim mode" do
200
- template = Tilt::ERBTemplate.new('test.erb', :trim => '-') { "\n<%= 1 + 1 -%>\n" }
201
- assert_equal "\n2", template.render(Scope.new)
202
- end
203
-
204
- test "shorthand whole line syntax trim mode" do
205
- template = Tilt::ERBTemplate.new('test.erb', :trim => '%') { "\n% if true\nhello\n%end\n" }
206
- assert_equal "\nhello\n", template.render(Scope.new)
207
- end
208
-
209
- test "encoding with magic comment" do
210
- f = Tempfile.open("template")
211
- f.puts('<%# coding: UTF-8 %>')
212
- f.puts('ふが <%= @hoge %>')
213
- f.close()
214
- @hoge = "ほげ"
215
- erb = Tilt::ERBTemplate.new(f.path)
216
- 3.times { erb.render(self) }
217
- f.delete
218
- end
219
-
220
- test "encoding with :default_encoding" do
221
- f = Tempfile.open("template")
222
- f.puts('ふが <%= @hoge %>')
223
- f.close()
224
- @hoge = "ほげ"
225
- erb = Tilt::ERBTemplate.new(f.path, :default_encoding => 'UTF-8')
226
- 3.times { erb.render(self) }
227
- f.delete
228
- end
229
- end
230
-
231
- __END__
232
- <html>
233
- <body>
234
- <h1>Hey <%= name %>!</h1>
235
-
236
-
237
- <p><% fail %></p>
238
- </body>
239
- </html>
@@ -1,151 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- begin
5
- require 'tilt/erubis'
6
- class ErubisTemplateTest < Minitest::Test
7
- test "registered for '.erubis' files" do
8
- assert_equal Tilt::ErubisTemplate, Tilt['test.erubis']
9
- assert_equal Tilt::ErubisTemplate, Tilt['test.html.erubis']
10
- end
11
-
12
- test "registered above ERB" do
13
- %w[erb rhtml].each do |ext|
14
- lazy = Tilt.lazy_map[ext]
15
- erubis_idx = lazy.index { |klass, file| klass == 'Tilt::ErubisTemplate' }
16
- erb_idx = lazy.index { |klass, file| klass == 'Tilt::ERBTemplate' }
17
- assert erubis_idx < erb_idx,
18
- "#{erubis_idx} should be lower than #{erb_idx}"
19
- end
20
- end
21
-
22
- test "preparing and evaluating templates on #render" do
23
- template = Tilt::ErubisTemplate.new { |t| "Hello World!" }
24
- assert_equal "Hello World!", template.render
25
- end
26
-
27
- test "can be rendered more than once" do
28
- template = Tilt::ErubisTemplate.new { |t| "Hello World!" }
29
- 3.times { assert_equal "Hello World!", template.render }
30
- end
31
-
32
- test "passing locals" do
33
- template = Tilt::ErubisTemplate.new { 'Hey <%= name %>!' }
34
- assert_equal "Hey Joe!", template.render(Object.new, :name => 'Joe')
35
- end
36
-
37
- test "evaluating in an object scope" do
38
- template = Tilt::ErubisTemplate.new { 'Hey <%= @name %>!' }
39
- scope = Object.new
40
- scope.instance_variable_set :@name, 'Joe'
41
- assert_equal "Hey Joe!", template.render(scope)
42
- end
43
-
44
- class MockOutputVariableScope
45
- attr_accessor :exposed_buffer
46
- end
47
-
48
- test "exposing the buffer to the template by default" do
49
- begin
50
- Tilt::ErubisTemplate.default_output_variable = '@_out_buf'
51
- template = Tilt::ErubisTemplate.new { '<% self.exposed_buffer = @_out_buf %>hey' }
52
- scope = MockOutputVariableScope.new
53
- template.render(scope)
54
- refute_nil scope.exposed_buffer
55
- assert_equal scope.exposed_buffer, 'hey'
56
- ensure
57
- Tilt::ErubisTemplate.default_output_variable = '_erbout'
58
- end
59
- end
60
-
61
- test "passing a block for yield" do
62
- template = Tilt::ErubisTemplate.new { 'Hey <%= yield %>!' }
63
- assert_equal "Hey Joe!", template.render { 'Joe' }
64
- end
65
-
66
- test "backtrace file and line reporting without locals" do
67
- data = File.read(__FILE__).split("\n__END__\n").last
68
- fail unless data[0] == ?<
69
- template = Tilt::ErubisTemplate.new('test.erubis', 11) { data }
70
- begin
71
- template.render
72
- fail 'should have raised an exception'
73
- rescue => boom
74
- assert_kind_of NameError, boom
75
- line = boom.backtrace.grep(/^test\.erubis:/).first
76
- assert line, "Backtrace didn't contain test.erubis"
77
- _file, line, _meth = line.split(":")
78
- assert_equal '13', line
79
- end
80
- end
81
-
82
- test "backtrace file and line reporting with locals" do
83
- data = File.read(__FILE__).split("\n__END__\n").last
84
- fail unless data[0] == ?<
85
- template = Tilt::ErubisTemplate.new('test.erubis', 1) { data }
86
- begin
87
- template.render(nil, :name => 'Joe', :foo => 'bar')
88
- fail 'should have raised an exception'
89
- rescue => boom
90
- assert_kind_of RuntimeError, boom
91
- line = boom.backtrace.first
92
- file, line, _meth = line.split(":")
93
- assert_equal 'test.erubis', file
94
- assert_equal '6', line
95
- end
96
- end
97
-
98
- test "erubis template options" do
99
- template = Tilt::ErubisTemplate.new(nil, :pattern => '\{% %\}') { 'Hey {%= @name %}!' }
100
- scope = Object.new
101
- scope.instance_variable_set :@name, 'Joe'
102
- assert_equal "Hey Joe!", template.render(scope)
103
- end
104
-
105
- test "using an instance variable as the outvar" do
106
- template = Tilt::ErubisTemplate.new(nil, :outvar => '@buf') { "<%= 1 + 1 %>" }
107
- scope = Object.new
108
- scope.instance_variable_set(:@buf, 'original value')
109
- assert_equal '2', template.render(scope)
110
- assert_equal 'original value', scope.instance_variable_get(:@buf)
111
- end
112
-
113
- test "using Erubis::EscapedEruby subclass via :engine_class option" do
114
- template = Tilt::ErubisTemplate.new(nil, :engine_class => ::Erubis::EscapedEruby) { |t| %(<%= "<p>Hello World!</p>" %>) }
115
- assert_equal "&lt;p&gt;Hello World!&lt;/p&gt;", template.render
116
- end
117
-
118
- test "using :escape_html => true option" do
119
- template = Tilt::ErubisTemplate.new(nil, :escape_html => true) { |t| %(<%= "<p>Hello World!</p>" %>) }
120
- assert_equal "&lt;p&gt;Hello World!&lt;/p&gt;", template.render
121
- end
122
-
123
- test "using :escape_html => false option" do
124
- template = Tilt::ErubisTemplate.new(nil, :escape_html => false) { |t| %(<%= "<p>Hello World!</p>" %>) }
125
- assert_equal "<p>Hello World!</p>", template.render
126
- end
127
-
128
- test "erubis default does not escape html" do
129
- template = Tilt::ErubisTemplate.new { |t| %(<%= "<p>Hello World!</p>" %>) }
130
- assert_equal "<p>Hello World!</p>", template.render
131
- end
132
-
133
- test "does not modify options argument" do
134
- options_hash = {:escape_html => true}
135
- Tilt::ErubisTemplate.new(nil, options_hash) { |t| "Hello World!" }
136
- assert_equal({:escape_html => true}, options_hash)
137
- end
138
- end
139
- rescue LoadError
140
- warn "Tilt::ErubisTemplate (disabled)"
141
- end
142
-
143
- __END__
144
- <html>
145
- <body>
146
- <h1>Hey <%= name %>!</h1>
147
-
148
-
149
- <p><% fail %></p>
150
- </body>
151
- </html>