tilt 1.4.1 → 2.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/COPYING +1 -1
  3. data/bin/tilt +18 -8
  4. data/lib/tilt/asciidoc.rb +1 -8
  5. data/lib/tilt/babel.rb +16 -0
  6. data/lib/tilt/bluecloth.rb +24 -0
  7. data/lib/tilt/builder.rb +12 -15
  8. data/lib/tilt/coffee.rb +10 -6
  9. data/lib/tilt/commonmarker.rb +88 -0
  10. data/lib/tilt/creole.rb +25 -0
  11. data/lib/tilt/csv.rb +12 -18
  12. data/lib/tilt/dummy.rb +3 -0
  13. data/lib/tilt/erb.rb +9 -56
  14. data/lib/tilt/erubi.rb +32 -0
  15. data/lib/tilt/erubis.rb +43 -0
  16. data/lib/tilt/haml.rb +66 -44
  17. data/lib/tilt/kramdown.rb +25 -0
  18. data/lib/tilt/less.rb +30 -0
  19. data/lib/tilt/liquid.rb +9 -10
  20. data/lib/tilt/livescript.rb +23 -0
  21. data/lib/tilt/mapping.rb +293 -0
  22. data/lib/tilt/markaby.rb +1 -8
  23. data/lib/tilt/maruku.rb +22 -0
  24. data/lib/tilt/nokogiri.rb +1 -8
  25. data/lib/tilt/pandoc.rb +57 -0
  26. data/lib/tilt/plain.rb +0 -4
  27. data/lib/tilt/prawn.rb +43 -0
  28. data/lib/tilt/radius.rb +1 -8
  29. data/lib/tilt/rdiscount.rb +39 -0
  30. data/lib/tilt/rdoc.rb +3 -10
  31. data/lib/tilt/redcarpet.rb +86 -0
  32. data/lib/tilt/{textile.rb → redcloth.rb} +1 -8
  33. data/lib/tilt/rst-pandoc.rb +23 -0
  34. data/lib/tilt/sass.rb +78 -0
  35. data/lib/tilt/sigil.rb +34 -0
  36. data/lib/tilt/string.rb +1 -1
  37. data/lib/tilt/template.rb +121 -105
  38. data/lib/tilt/typescript.rb +26 -0
  39. data/lib/tilt/wikicloth.rb +22 -0
  40. data/lib/tilt/yajl.rb +1 -8
  41. data/lib/tilt.rb +118 -155
  42. metadata +38 -469
  43. data/CHANGELOG.md +0 -44
  44. data/Gemfile +0 -32
  45. data/HACKING +0 -16
  46. data/README.md +0 -232
  47. data/Rakefile +0 -104
  48. data/TEMPLATES.md +0 -516
  49. data/lib/tilt/css.rb +0 -80
  50. data/lib/tilt/markdown.rb +0 -214
  51. data/lib/tilt/wiki.rb +0 -58
  52. data/test/contest.rb +0 -68
  53. data/test/markaby/locals.mab +0 -1
  54. data/test/markaby/markaby.mab +0 -1
  55. data/test/markaby/markaby_other_static.mab +0 -1
  56. data/test/markaby/render_twice.mab +0 -1
  57. data/test/markaby/scope.mab +0 -1
  58. data/test/markaby/yielding.mab +0 -2
  59. data/test/tilt_asciidoctor_test.rb +0 -44
  60. data/test/tilt_blueclothtemplate_test.rb +0 -45
  61. data/test/tilt_buildertemplate_test.rb +0 -59
  62. data/test/tilt_cache_test.rb +0 -32
  63. data/test/tilt_coffeescripttemplate_test.rb +0 -114
  64. data/test/tilt_compilesite_test.rb +0 -51
  65. data/test/tilt_creoletemplate_test.rb +0 -28
  66. data/test/tilt_csv_test.rb +0 -69
  67. data/test/tilt_erbtemplate_test.rb +0 -239
  68. data/test/tilt_erubistemplate_test.rb +0 -151
  69. data/test/tilt_etannitemplate_test.rb +0 -173
  70. data/test/tilt_fallback_test.rb +0 -122
  71. data/test/tilt_hamltemplate_test.rb +0 -144
  72. data/test/tilt_kramdown_test.rb +0 -42
  73. data/test/tilt_lesstemplate_test.less +0 -1
  74. data/test/tilt_lesstemplate_test.rb +0 -42
  75. data/test/tilt_liquidtemplate_test.rb +0 -78
  76. data/test/tilt_markaby_test.rb +0 -88
  77. data/test/tilt_markdown_test.rb +0 -172
  78. data/test/tilt_marukutemplate_test.rb +0 -48
  79. data/test/tilt_nokogiritemplate_test.rb +0 -87
  80. data/test/tilt_radiustemplate_test.rb +0 -75
  81. data/test/tilt_rdiscounttemplate_test.rb +0 -55
  82. data/test/tilt_rdoctemplate_test.rb +0 -31
  83. data/test/tilt_redcarpettemplate_test.rb +0 -71
  84. data/test/tilt_redclothtemplate_test.rb +0 -36
  85. data/test/tilt_sasstemplate_test.rb +0 -41
  86. data/test/tilt_stringtemplate_test.rb +0 -170
  87. data/test/tilt_template_test.rb +0 -323
  88. data/test/tilt_test.rb +0 -65
  89. data/test/tilt_wikiclothtemplate_test.rb +0 -32
  90. data/test/tilt_yajltemplate_test.rb +0 -101
  91. data/tilt.gemspec +0 -120
@@ -1,51 +0,0 @@
1
- require 'contest'
2
- require 'tilt'
3
- require 'thread'
4
-
5
- class CompileSiteTest < Test::Unit::TestCase
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,28 +0,0 @@
1
- require 'contest'
2
- require 'tilt'
3
-
4
- begin
5
- require 'creole'
6
-
7
- class CreoleTemplateTest < Test::Unit::TestCase
8
- test "is registered for '.creole' files" do
9
- assert_equal Tilt::CreoleTemplate, Tilt['test.creole']
10
- end
11
-
12
- test "registered for '.wiki' files" do
13
- assert Tilt.mappings['wiki'].include?(Tilt::CreoleTemplate)
14
- end
15
-
16
- test "compiles and evaluates the template on #render" do
17
- template = Tilt::CreoleTemplate.new { |t| "= Hello World!" }
18
- assert_equal "<h1>Hello World!</h1>", template.render
19
- end
20
-
21
- test "can be rendered more than once" do
22
- template = Tilt::CreoleTemplate.new { |t| "= Hello World!" }
23
- 3.times { assert_equal "<h1>Hello World!</h1>", template.render }
24
- end
25
- end
26
- rescue LoadError => boom
27
- warn "Tilt::CreoleTemplate (disabled)"
28
- end
@@ -1,69 +0,0 @@
1
- require 'contest'
2
- require 'tilt'
3
-
4
- begin
5
- if RUBY_VERSION >= '1.9.0'
6
- require 'csv'
7
- else
8
- require 'fastercsv'
9
- end
10
-
11
- class CSVTemplateTest < Test::Unit::TestCase
12
-
13
- test "registered for '.rcsv' files" do
14
- assert Tilt.mappings['rcsv'].include?(Tilt::CSVTemplate)
15
- end
16
-
17
- test "compiles and evaluates the template on #render" do
18
- template = Tilt::CSVTemplate.new { "csv << ['hello', 'world']" }
19
- assert_equal "hello,world\n", template.render
20
- end
21
-
22
- test "can be rendered more than once" do
23
- template = Tilt::CSVTemplate.new { "csv << [1,2,3]" }
24
- 3.times { assert_equal "1,2,3\n", template.render }
25
- end
26
-
27
- test "can pass locals" do
28
- template = Tilt::CSVTemplate.new { 'csv << [1, name]' }
29
- assert_equal "1,Joe\n", template.render(Object.new, :name => 'Joe')
30
- end
31
-
32
- test "evaluating in an object scope" do
33
- template = Tilt::CSVTemplate.new { 'csv << [1, @name]' }
34
- scope = Object.new
35
- scope.instance_variable_set :@name, 'Joe'
36
- assert_equal "1,Joe\n", template.render(scope)
37
- end
38
-
39
- test "backtrace file and line reporting" do
40
- data = File.read(__FILE__).split("\n__END__\n").last
41
- template = Tilt::CSVTemplate.new('test.csv') { data }
42
- begin
43
- template.render
44
- fail 'should have raised an exception'
45
- rescue => boom
46
- assert_kind_of NameError, boom
47
- line = boom.backtrace.grep(/^test\.csv:/).first
48
- assert line, "Backtrace didn't contain test.csv"
49
- file, line, meth = line.split(":")
50
- assert_equal '4', line
51
- end
52
- end
53
-
54
- end
55
-
56
- rescue LoadError => boom
57
- warn "Tilt::CSVTemplate (disabled) please install 'fastercsv' if using ruby 1.8.x"
58
- end
59
-
60
-
61
- __END__
62
- # header
63
- csv << ['Type', 'Age']
64
-
65
- raise NameError
66
-
67
- # rows
68
- csv << ['Frog', 2]
69
- csv << ['Cat', 5]
@@ -1,239 +0,0 @@
1
- # coding: utf-8
2
- require 'contest'
3
- require 'tilt'
4
- require 'erb'
5
- require 'tempfile'
6
-
7
- class ERBTemplateTest < Test::Unit::TestCase
8
- test "registered for '.erb' files" do
9
- assert Tilt.mappings['erb'].include?(Tilt::ERBTemplate)
10
- end
11
-
12
- test "registered for '.rhtml' files" do
13
- assert Tilt.mappings['rhtml'].include?(Tilt::ERBTemplate)
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
- assert_not_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 < Test::Unit::TestCase
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 'contest'
2
- require 'tilt'
3
-
4
- begin
5
- require 'erubis'
6
- class ErubisTemplateTest < Test::Unit::TestCase
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
- mappings = Tilt.mappings[ext]
15
- erubis_idx = mappings.index(Tilt::ErubisTemplate)
16
- erb_idx = mappings.index(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
- assert_not_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
- template = Tilt::ErubisTemplate.new(nil, options_hash) { |t| "Hello World!" }
136
- assert_equal({:escape_html => true}, options_hash)
137
- end
138
- end
139
- rescue LoadError => boom
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>