tilt 2.0.9 → 2.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tilt.rb +1 -1
- data/lib/tilt/template.rb +7 -12
- metadata +3 -104
- data/CHANGELOG.md +0 -132
- data/Gemfile +0 -70
- data/HACKING +0 -16
- data/README.md +0 -233
- data/Rakefile +0 -106
- data/docs/TEMPLATES.md +0 -555
- data/docs/common.css +0 -14
- data/man/index.txt +0 -2
- data/man/tilt.1.ronn +0 -59
- data/test/markaby/locals.mab +0 -1
- data/test/markaby/markaby.mab +0 -1
- data/test/markaby/markaby_other_static.mab +0 -1
- data/test/markaby/render_twice.mab +0 -1
- data/test/markaby/scope.mab +0 -1
- data/test/markaby/yielding.mab +0 -2
- data/test/mytemplate.rb +0 -2
- data/test/test_helper.rb +0 -64
- data/test/tilt_asciidoctor_test.rb +0 -50
- data/test/tilt_babeltemplate.rb +0 -33
- data/test/tilt_blueclothtemplate_test.rb +0 -33
- data/test/tilt_buildertemplate_test.rb +0 -72
- data/test/tilt_cache_test.rb +0 -43
- data/test/tilt_coffeescripttemplate_test.rb +0 -141
- data/test/tilt_commonmarkertemplate_test.rb +0 -28
- data/test/tilt_compilesite_test.rb +0 -51
- data/test/tilt_creoletemplate_test.rb +0 -24
- data/test/tilt_csv_test.rb +0 -77
- data/test/tilt_erbtemplate_test.rb +0 -239
- data/test/tilt_erubistemplate_test.rb +0 -151
- data/test/tilt_erubitemplate_test.rb +0 -158
- data/test/tilt_etannitemplate_test.rb +0 -174
- data/test/tilt_hamltemplate_test.rb +0 -166
- data/test/tilt_kramdown_test.rb +0 -20
- data/test/tilt_lesstemplate_test.less +0 -1
- data/test/tilt_lesstemplate_test.rb +0 -42
- data/test/tilt_liquidtemplate_test.rb +0 -87
- data/test/tilt_livescripttemplate_test.rb +0 -37
- data/test/tilt_mapping_test.rb +0 -232
- data/test/tilt_markaby_test.rb +0 -88
- data/test/tilt_markdown_test.rb +0 -186
- data/test/tilt_marukutemplate_test.rb +0 -36
- data/test/tilt_metadata_test.rb +0 -42
- data/test/tilt_nokogiritemplate_test.rb +0 -87
- data/test/tilt_pandoctemplate_test.rb +0 -67
- data/test/tilt_prawntemplate.prawn +0 -1
- data/test/tilt_prawntemplate_test.rb +0 -75
- data/test/tilt_radiustemplate_test.rb +0 -75
- data/test/tilt_rdiscounttemplate_test.rb +0 -43
- data/test/tilt_rdoctemplate_test.rb +0 -29
- data/test/tilt_redcarpettemplate_test.rb +0 -54
- data/test/tilt_redclothtemplate_test.rb +0 -36
- data/test/tilt_rstpandoctemplate_test.rb +0 -32
- data/test/tilt_sasstemplate_test.rb +0 -42
- data/test/tilt_sigil_test.rb +0 -41
- data/test/tilt_stringtemplate_test.rb +0 -171
- data/test/tilt_template_test.rb +0 -314
- data/test/tilt_test.rb +0 -60
- data/test/tilt_typescript_test.rb +0 -38
- data/test/tilt_wikiclothtemplate_test.rb +0 -32
- data/test/tilt_yajltemplate_test.rb +0 -101
- data/tilt.gemspec +0 -130
data/test/tilt_kramdown_test.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'tilt/kramdown'
|
6
|
-
|
7
|
-
class KramdownTemplateTest < Minitest::Test
|
8
|
-
test "preparing and evaluating templates on #render" do
|
9
|
-
template = Tilt::KramdownTemplate.new { |t| "# Hello World!" }
|
10
|
-
assert_equal '<h1 id="hello-world">Hello World!</h1>', template.render.strip
|
11
|
-
end
|
12
|
-
|
13
|
-
test "can be rendered more than once" do
|
14
|
-
template = Tilt::KramdownTemplate.new { |t| "# Hello World!" }
|
15
|
-
3.times { assert_equal '<h1 id="hello-world">Hello World!</h1>', template.render.strip }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
rescue LoadError
|
19
|
-
warn "Tilt::KramdownTemplate (disabled)"
|
20
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
@text-color: #ffc0cb;
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'pathname'
|
6
|
-
require 'tilt/less'
|
7
|
-
|
8
|
-
class LessTemplateTest < Minitest::Test
|
9
|
-
def assert_similar(a, b)
|
10
|
-
assert_equal a.gsub(/\s+/m, ' '), b.gsub(/\s+/m, ' ')
|
11
|
-
end
|
12
|
-
|
13
|
-
test "is registered for '.less' files" do
|
14
|
-
assert_equal Tilt::LessTemplate, Tilt['test.less']
|
15
|
-
end
|
16
|
-
|
17
|
-
test "compiles and evaluates the template on #render" do
|
18
|
-
template = Tilt::LessTemplate.new { |t| ".bg { background-color: #0000ff; } \n#main\n { .bg; }\n" }
|
19
|
-
assert_similar ".bg {\n background-color: #0000ff;\n}\n#main {\n background-color: #0000ff;\n}\n", template.render
|
20
|
-
end
|
21
|
-
|
22
|
-
test "can be rendered more than once" do
|
23
|
-
template = Tilt::LessTemplate.new { |t| ".bg { background-color: #0000ff; } \n#main\n { .bg; }\n" }
|
24
|
-
3.times { assert_similar ".bg {\n background-color: #0000ff;\n}\n#main {\n background-color: #0000ff;\n}\n", template.render }
|
25
|
-
end
|
26
|
-
|
27
|
-
test "can be passed a load path" do
|
28
|
-
template = Tilt::LessTemplate.new({
|
29
|
-
:paths => [Pathname(__FILE__).dirname]
|
30
|
-
}) {
|
31
|
-
<<-EOLESS
|
32
|
-
@import 'tilt_lesstemplate_test.less';
|
33
|
-
.bg {background-color: @text-color;}
|
34
|
-
EOLESS
|
35
|
-
}
|
36
|
-
assert_similar ".bg {\n background-color: #ffc0cb;\n}\n", template.render
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
rescue LoadError
|
41
|
-
warn "Tilt::LessTemplate (disabled)"
|
42
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'tilt/liquid'
|
6
|
-
|
7
|
-
class LiquidTemplateTest < Minitest::Test
|
8
|
-
test "registered for '.liquid' files" do
|
9
|
-
assert_equal Tilt::LiquidTemplate, Tilt['test.liquid']
|
10
|
-
end
|
11
|
-
|
12
|
-
test "preparing and evaluating templates on #render" do
|
13
|
-
template = Tilt::LiquidTemplate.new { |t| "Hello World!" }
|
14
|
-
assert_equal "Hello World!", template.render
|
15
|
-
end
|
16
|
-
|
17
|
-
test "can be rendered more than once" do
|
18
|
-
template = Tilt::LiquidTemplate.new { |t| "Hello World!" }
|
19
|
-
3.times { assert_equal "Hello World!", template.render }
|
20
|
-
end
|
21
|
-
|
22
|
-
test "passing locals" do
|
23
|
-
template = Tilt::LiquidTemplate.new { "Hey {{ name }}!" }
|
24
|
-
assert_equal "Hey Joe!", template.render(nil, :name => 'Joe')
|
25
|
-
end
|
26
|
-
|
27
|
-
test "options can be set" do
|
28
|
-
err = assert_raises(Liquid::SyntaxError) do
|
29
|
-
options = { line_numbers: false, error_mode: :strict }
|
30
|
-
Tilt::LiquidTemplate.new(options) { "{{%%%}}" }.render
|
31
|
-
end
|
32
|
-
assert_equal 'Liquid syntax error: Unexpected character % in "{{%%%}}"',
|
33
|
-
err.message
|
34
|
-
end
|
35
|
-
|
36
|
-
# Object's passed as "scope" to LiquidTemplate may respond to
|
37
|
-
# #to_h with a Hash. The Hash's contents are merged underneath
|
38
|
-
# Tilt locals.
|
39
|
-
class ExampleLiquidScope
|
40
|
-
def to_h
|
41
|
-
{ :beer => 'wet', :whisky => 'wetter' }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
test "combining scope and locals when scope responds to #to_h" do
|
46
|
-
template =
|
47
|
-
Tilt::LiquidTemplate.new {
|
48
|
-
'Beer is {{ beer }} but Whisky is {{ whisky }}.'
|
49
|
-
}
|
50
|
-
scope = ExampleLiquidScope.new
|
51
|
-
assert_equal "Beer is wet but Whisky is wetter.", template.render(scope)
|
52
|
-
end
|
53
|
-
|
54
|
-
test "precedence when locals and scope define same variables" do
|
55
|
-
template =
|
56
|
-
Tilt::LiquidTemplate.new {
|
57
|
-
'Beer is {{ beer }} but Whisky is {{ whisky }}.'
|
58
|
-
}
|
59
|
-
scope = ExampleLiquidScope.new
|
60
|
-
assert_equal "Beer is great but Whisky is greater.",
|
61
|
-
template.render(scope, :beer => 'great', :whisky => 'greater')
|
62
|
-
end
|
63
|
-
|
64
|
-
# Object's passed as "scope" to LiquidTemplate that do not
|
65
|
-
# respond to #to_h are silently ignored.
|
66
|
-
class ExampleIgnoredLiquidScope
|
67
|
-
end
|
68
|
-
|
69
|
-
test "handling scopes that do not respond to #to_h" do
|
70
|
-
template = Tilt::LiquidTemplate.new { 'Whisky' }
|
71
|
-
scope = ExampleIgnoredLiquidScope.new
|
72
|
-
assert_equal "Whisky", template.render(scope)
|
73
|
-
end
|
74
|
-
|
75
|
-
test "passing a block for yield" do
|
76
|
-
template =
|
77
|
-
Tilt::LiquidTemplate.new {
|
78
|
-
'Beer is {{ yield }} but Whisky is {{ content }}ter.'
|
79
|
-
}
|
80
|
-
assert_equal "Beer is wet but Whisky is wetter.",
|
81
|
-
template.render({}) { 'wet' }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
rescue LoadError
|
86
|
-
warn "Tilt::LiquidTemplate (disabled)"
|
87
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'tilt/livescript'
|
6
|
-
|
7
|
-
class LiveScriptTemplateTest < Minitest::Test
|
8
|
-
setup do
|
9
|
-
@code_without_variables = "puts 'Hello, World!'\n"
|
10
|
-
@renderer = Tilt::LiveScriptTemplate
|
11
|
-
end
|
12
|
-
|
13
|
-
test "compiles and evaluates the template on #render" do
|
14
|
-
template = @renderer.new { |t| @code_without_variables }
|
15
|
-
assert_match "puts('Hello, World!');", template.render
|
16
|
-
end
|
17
|
-
|
18
|
-
test "can be rendered more than once" do
|
19
|
-
template = @renderer.new { |t| @code_without_variables }
|
20
|
-
3.times { assert_match "puts('Hello, World!');", template.render }
|
21
|
-
end
|
22
|
-
|
23
|
-
test "supports bare-option" do
|
24
|
-
template = @renderer.new(:bare => false) { |t| @code_without_variables }
|
25
|
-
assert_match "function", template.render
|
26
|
-
|
27
|
-
template = @renderer.new(:bare => true) { |t| @code_without_variables }
|
28
|
-
refute_match "function", template.render
|
29
|
-
end
|
30
|
-
|
31
|
-
test "is registered for '.ls' files" do
|
32
|
-
assert_equal @renderer, Tilt['test.ls']
|
33
|
-
end
|
34
|
-
end
|
35
|
-
rescue LoadError
|
36
|
-
warn "Tilt::LiveScriptTemplate (disabled)"
|
37
|
-
end
|
data/test/tilt_mapping_test.rb
DELETED
@@ -1,232 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'tilt'
|
3
|
-
require 'tilt/mapping'
|
4
|
-
|
5
|
-
module Tilt
|
6
|
-
|
7
|
-
class MappingTest < Minitest::Test
|
8
|
-
class Stub
|
9
|
-
end
|
10
|
-
|
11
|
-
class Stub2
|
12
|
-
end
|
13
|
-
|
14
|
-
setup do
|
15
|
-
@mapping = Mapping.new
|
16
|
-
end
|
17
|
-
|
18
|
-
test "registered?" do
|
19
|
-
@mapping.register(Stub, 'foo', 'bar')
|
20
|
-
assert @mapping.registered?('foo')
|
21
|
-
assert @mapping.registered?('bar')
|
22
|
-
refute @mapping.registered?('baz')
|
23
|
-
end
|
24
|
-
|
25
|
-
test "lookups on registered" do
|
26
|
-
@mapping.register(Stub, 'foo', 'bar')
|
27
|
-
assert_equal Stub, @mapping['foo']
|
28
|
-
assert_equal Stub, @mapping['bar']
|
29
|
-
assert_equal Stub, @mapping['hello.foo']
|
30
|
-
assert_nil @mapping['foo.baz']
|
31
|
-
end
|
32
|
-
|
33
|
-
test "can be dup'd" do
|
34
|
-
@mapping.register(Stub, 'foo')
|
35
|
-
other = @mapping.dup
|
36
|
-
assert other.registered?('foo')
|
37
|
-
|
38
|
-
# @mapping doesn't leak to other
|
39
|
-
@mapping.register(Stub, 'bar')
|
40
|
-
refute other.registered?('bar')
|
41
|
-
|
42
|
-
# other doesn't leak to @mapping
|
43
|
-
other.register(Stub, 'baz')
|
44
|
-
refute @mapping.registered?('baz')
|
45
|
-
end
|
46
|
-
|
47
|
-
test "#extensions_for" do
|
48
|
-
@mapping.register(Stub, 'foo', 'bar')
|
49
|
-
assert_equal ['foo', 'bar'].sort, @mapping.extensions_for(Stub).sort
|
50
|
-
end
|
51
|
-
|
52
|
-
test "supports old-style #register" do
|
53
|
-
@mapping.register('foo', Stub)
|
54
|
-
assert_equal Stub, @mapping['foo']
|
55
|
-
end
|
56
|
-
|
57
|
-
context "lazy with one template class" do
|
58
|
-
setup do
|
59
|
-
@mapping.register_lazy('MyTemplate', 'my_template', 'mt')
|
60
|
-
@loaded_before = $LOADED_FEATURES.dup
|
61
|
-
end
|
62
|
-
|
63
|
-
teardown do
|
64
|
-
Object.send :remove_const, :MyTemplate if defined? ::MyTemplate
|
65
|
-
$LOADED_FEATURES.replace(@loaded_before)
|
66
|
-
end
|
67
|
-
|
68
|
-
test "registered?" do
|
69
|
-
assert @mapping.registered?('mt')
|
70
|
-
end
|
71
|
-
|
72
|
-
test "#extensions_for" do
|
73
|
-
assert_equal ['mt'], @mapping.extensions_for('MyTemplate')
|
74
|
-
end
|
75
|
-
|
76
|
-
test "basic lookup" do
|
77
|
-
req = proc do |file|
|
78
|
-
assert_equal 'my_template', file
|
79
|
-
class ::MyTemplate; end
|
80
|
-
true
|
81
|
-
end
|
82
|
-
|
83
|
-
@mapping.stub :require, req do
|
84
|
-
klass = @mapping['hello.mt']
|
85
|
-
assert_equal ::MyTemplate, klass
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
test "doesn't require when template class is present" do
|
90
|
-
class ::MyTemplate; end
|
91
|
-
|
92
|
-
req = proc do |file|
|
93
|
-
flunk "#require shouldn't be called"
|
94
|
-
end
|
95
|
-
|
96
|
-
@mapping.stub :require, req do
|
97
|
-
klass = @mapping['hello.mt']
|
98
|
-
assert_equal ::MyTemplate, klass
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
test "doesn't require when the template class is autoloaded, and then defined" do
|
103
|
-
Object.autoload :MyTemplate, 'mytemplate'
|
104
|
-
did_load = require 'mytemplate'
|
105
|
-
assert did_load, "mytemplate wasn't freshly required"
|
106
|
-
|
107
|
-
req = proc do |file|
|
108
|
-
flunk "#require shouldn't be called"
|
109
|
-
end
|
110
|
-
|
111
|
-
@mapping.stub :require, req do
|
112
|
-
klass = @mapping['hello.mt']
|
113
|
-
assert_equal ::MyTemplate, klass
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
test "raises NameError when the class name is defined" do
|
118
|
-
req = proc do |file|
|
119
|
-
# do nothing
|
120
|
-
end
|
121
|
-
|
122
|
-
@mapping.stub :require, req do
|
123
|
-
assert_raises(NameError) do
|
124
|
-
@mapping['hello.mt']
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context "lazy with two template classes" do
|
131
|
-
setup do
|
132
|
-
@mapping.register_lazy('MyTemplate1', 'my_template1', 'mt')
|
133
|
-
@mapping.register_lazy('MyTemplate2', 'my_template2', 'mt')
|
134
|
-
end
|
135
|
-
|
136
|
-
teardown do
|
137
|
-
Object.send :remove_const, :MyTemplate1 if defined? ::MyTemplate1
|
138
|
-
Object.send :remove_const, :MyTemplate2 if defined? ::MyTemplate2
|
139
|
-
end
|
140
|
-
|
141
|
-
test "registered?" do
|
142
|
-
assert @mapping.registered?('mt')
|
143
|
-
end
|
144
|
-
|
145
|
-
test "only attempt to load the last template" do
|
146
|
-
req = proc do |file|
|
147
|
-
assert_equal 'my_template2', file
|
148
|
-
class ::MyTemplate2; end
|
149
|
-
true
|
150
|
-
end
|
151
|
-
|
152
|
-
@mapping.stub :require, req do
|
153
|
-
klass = @mapping['hello.mt']
|
154
|
-
assert_equal ::MyTemplate2, klass
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
test "uses the first template if it's present" do
|
159
|
-
class ::MyTemplate1; end
|
160
|
-
|
161
|
-
req = proc do |file|
|
162
|
-
flunk
|
163
|
-
end
|
164
|
-
|
165
|
-
@mapping.stub :require, req do
|
166
|
-
klass = @mapping['hello.mt']
|
167
|
-
assert_equal ::MyTemplate1, klass
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
test "falls back when LoadError is thrown" do
|
172
|
-
req = proc do |file|
|
173
|
-
raise LoadError unless file == 'my_template1'
|
174
|
-
class ::MyTemplate1; end
|
175
|
-
true
|
176
|
-
end
|
177
|
-
|
178
|
-
@mapping.stub :require, req do
|
179
|
-
klass = @mapping['hello.mt']
|
180
|
-
assert_equal ::MyTemplate1, klass
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
test "raises the first LoadError when everything fails" do
|
185
|
-
req = proc do |file|
|
186
|
-
raise LoadError, file
|
187
|
-
end
|
188
|
-
|
189
|
-
@mapping.stub :require, req do
|
190
|
-
err = assert_raises(LoadError) do
|
191
|
-
@mapping['hello.mt']
|
192
|
-
end
|
193
|
-
|
194
|
-
assert_equal 'my_template2', err.message
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
test "handles autoloaded constants" do
|
199
|
-
Object.autoload :MyTemplate2, 'my_template2'
|
200
|
-
class ::MyTemplate1; end
|
201
|
-
|
202
|
-
assert_equal MyTemplate1, @mapping['hello.mt']
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
test "raises NameError on invalid class name" do
|
207
|
-
@mapping.register_lazy '#foo', 'my_template', 'mt'
|
208
|
-
|
209
|
-
req = proc do |file|
|
210
|
-
# do nothing
|
211
|
-
end
|
212
|
-
|
213
|
-
@mapping.stub :require, req do
|
214
|
-
assert_raises(NameError) do
|
215
|
-
@mapping['hello.mt']
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
context "#templates_for" do
|
221
|
-
setup do
|
222
|
-
@mapping.register Stub, 'a'
|
223
|
-
@mapping.register Stub2, 'b'
|
224
|
-
end
|
225
|
-
|
226
|
-
test "handles multiple engines" do
|
227
|
-
assert_equal [Stub2, Stub], @mapping.templates_for('hello/world.a.b')
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
data/test/tilt_markaby_test.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'tilt/markaby'
|
6
|
-
|
7
|
-
class MarkabyTiltTest < Minitest::Test
|
8
|
-
def setup
|
9
|
-
@block = lambda do |t|
|
10
|
-
File.read(File.dirname(__FILE__) + "/#{t.file}")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
test "should be able to render a markaby template with static html" do
|
15
|
-
tilt = Tilt::MarkabyTemplate.new("markaby/markaby.mab", &@block)
|
16
|
-
assert_equal "hello from markaby!", tilt.render
|
17
|
-
end
|
18
|
-
|
19
|
-
test "should use the contents of the template" do
|
20
|
-
tilt = ::Tilt::MarkabyTemplate.new("markaby/markaby_other_static.mab", &@block)
|
21
|
-
assert_equal "_why?", tilt.render
|
22
|
-
end
|
23
|
-
|
24
|
-
test "should render from a string (given as data)" do
|
25
|
-
tilt = ::Tilt::MarkabyTemplate.new { "html do; end" }
|
26
|
-
assert_equal "<html></html>", tilt.render
|
27
|
-
end
|
28
|
-
|
29
|
-
test "can be rendered more than once" do
|
30
|
-
tilt = ::Tilt::MarkabyTemplate.new { "html do; end" }
|
31
|
-
3.times { assert_equal "<html></html>", tilt.render }
|
32
|
-
end
|
33
|
-
|
34
|
-
test "should evaluate a template file in the scope given" do
|
35
|
-
scope = Object.new
|
36
|
-
def scope.foo
|
37
|
-
"bar"
|
38
|
-
end
|
39
|
-
|
40
|
-
tilt = ::Tilt::MarkabyTemplate.new("markaby/scope.mab", &@block)
|
41
|
-
assert_equal "<li>bar</li>", tilt.render(scope)
|
42
|
-
end
|
43
|
-
|
44
|
-
test "should pass locals to the template" do
|
45
|
-
tilt = ::Tilt::MarkabyTemplate.new("markaby/locals.mab", &@block)
|
46
|
-
assert_equal "<li>bar</li>", tilt.render(Object.new, { :foo => "bar" })
|
47
|
-
end
|
48
|
-
|
49
|
-
test "should yield to the block given" do
|
50
|
-
tilt = ::Tilt::MarkabyTemplate.new("markaby/yielding.mab", &@block)
|
51
|
-
eval_scope = Markaby::Builder.new
|
52
|
-
|
53
|
-
output = tilt.render(Object.new, {}) do
|
54
|
-
text("Joe")
|
55
|
-
end
|
56
|
-
|
57
|
-
assert_equal "Hey Joe", output
|
58
|
-
end
|
59
|
-
|
60
|
-
test "should be able to render two templates in a row" do
|
61
|
-
tilt = ::Tilt::MarkabyTemplate.new("markaby/render_twice.mab", &@block)
|
62
|
-
|
63
|
-
assert_equal "foo", tilt.render
|
64
|
-
assert_equal "foo", tilt.render
|
65
|
-
end
|
66
|
-
|
67
|
-
test "should retrieve a Tilt::MarkabyTemplate when calling Tilt['hello.mab']" do
|
68
|
-
assert_equal Tilt::MarkabyTemplate, ::Tilt['./markaby/markaby.mab']
|
69
|
-
end
|
70
|
-
|
71
|
-
test "should return a new instance of the implementation class (when calling Tilt.new)" do
|
72
|
-
assert ::Tilt.new(File.dirname(__FILE__) + "/markaby/markaby.mab").kind_of?(Tilt::MarkabyTemplate)
|
73
|
-
end
|
74
|
-
|
75
|
-
test "should be able to evaluate block style templates" do
|
76
|
-
tilt = Tilt::MarkabyTemplate.new { |t| lambda { h1 "Hello World!" }}
|
77
|
-
assert_equal "<h1>Hello World!</h1>", tilt.render
|
78
|
-
end
|
79
|
-
|
80
|
-
test "should pass locals to block style templates" do
|
81
|
-
tilt = Tilt::MarkabyTemplate.new { |t| lambda { h1 "Hello #{name}!" }}
|
82
|
-
assert_equal "<h1>Hello _why!</h1>", tilt.render(nil, :name => "_why")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
rescue LoadError
|
87
|
-
warn "Tilt::MarkabyTemplate (disabled)"
|
88
|
-
end
|