tilt 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -0
- data/TEMPLATES.md +2 -2
- data/lib/tilt.rb +1 -1
- data/lib/tilt/template.rb +4 -1
- data/test/tilt_template_test.rb +47 -0
- data/tilt.gemspec +2 -2
- metadata +3 -2
data/CHANGELOG.md
CHANGED
data/TEMPLATES.md
CHANGED
@@ -305,9 +305,9 @@ time when using this template engine within a threaded environment.
|
|
305
305
|
|
306
306
|
### See also
|
307
307
|
|
308
|
-
* [Liquid for Programmers](
|
308
|
+
* [Liquid for Programmers](https://wiki.github.com/Shopify/liquid/liquid-for-programmers)
|
309
309
|
* [Liquid Docs](http://liquid.rubyforge.org/)
|
310
|
-
* GitHub: [
|
310
|
+
* GitHub: [Shopify/liquid](https://github.com/Shopify/liquid/)
|
311
311
|
|
312
312
|
|
313
313
|
<a name='radius'></a>
|
data/lib/tilt.rb
CHANGED
data/lib/tilt/template.rb
CHANGED
@@ -194,7 +194,10 @@ module Tilt
|
|
194
194
|
template.force_encoding(template_encoding)
|
195
195
|
end
|
196
196
|
|
197
|
-
|
197
|
+
# https://github.com/rtomayko/tilt/issues/193
|
198
|
+
warn "precompiled_preamble should return String (not Array)" if preamble.is_a?(Array)
|
199
|
+
warn "precompiled_postamble should return String (not Array)" if postamble.is_a?(Array)
|
200
|
+
source << [preamble, template, postamble].join("\n")
|
198
201
|
|
199
202
|
[source, preamble.count("\n")+1]
|
200
203
|
end
|
data/test/tilt_template_test.rb
CHANGED
@@ -153,6 +153,53 @@ class TiltTemplateTest < Test::Unit::TestCase
|
|
153
153
|
assert_equal "1 + 2 = 3", inst.render(Object.new, '_answer' => 3)
|
154
154
|
end
|
155
155
|
|
156
|
+
class CustomGeneratingMockTemplate < PreparingMockTemplate
|
157
|
+
def precompiled_template(locals)
|
158
|
+
data
|
159
|
+
end
|
160
|
+
|
161
|
+
def precompiled_preamble(locals)
|
162
|
+
options.fetch(:preamble)
|
163
|
+
end
|
164
|
+
|
165
|
+
def precompiled_postamble(locals)
|
166
|
+
options.fetch(:postamble)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
test "supports pre/postamble" do
|
171
|
+
inst = CustomGeneratingMockTemplate.new(
|
172
|
+
:preamble => 'buf = []',
|
173
|
+
:postamble => 'buf.join'
|
174
|
+
) { 'buf << 1' }
|
175
|
+
|
176
|
+
assert_equal "1", inst.render
|
177
|
+
end
|
178
|
+
|
179
|
+
# Special-case for Haml
|
180
|
+
# https://github.com/rtomayko/tilt/issues/193
|
181
|
+
test "supports Array pre/postambles" do
|
182
|
+
inst = CustomGeneratingMockTemplate.new(
|
183
|
+
:preamble => ['buf = ', '[]'],
|
184
|
+
:postamble => ['buf.', 'join']
|
185
|
+
) { 'buf << 1' }
|
186
|
+
|
187
|
+
# TODO: Use assert_output when we swicth to MiniTest
|
188
|
+
warns = <<-EOF
|
189
|
+
precompiled_preamble should return String (not Array)
|
190
|
+
precompiled_postamble should return String (not Array)
|
191
|
+
EOF
|
192
|
+
|
193
|
+
begin
|
194
|
+
require 'stringio'
|
195
|
+
$stderr = StringIO.new
|
196
|
+
assert_equal "1", inst.render
|
197
|
+
assert_equal warns, $stderr.string
|
198
|
+
ensure
|
199
|
+
$stderr = STDERR
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
156
203
|
class Person
|
157
204
|
CONSTANT = "Bob"
|
158
205
|
|
data/tilt.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'tilt'
|
6
|
-
s.version = '1.4.
|
7
|
-
s.date = '2013-05-
|
6
|
+
s.version = '1.4.1'
|
7
|
+
s.date = '2013-05-08'
|
8
8
|
|
9
9
|
s.description = "Generic interface to multiple Ruby template engines"
|
10
10
|
s.summary = s.description
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tilt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor
|
@@ -518,3 +518,4 @@ test_files:
|
|
518
518
|
- test/tilt_test.rb
|
519
519
|
- test/tilt_wikiclothtemplate_test.rb
|
520
520
|
- test/tilt_yajltemplate_test.rb
|
521
|
+
has_rdoc:
|