roger 1.6.3 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -0
- data/lib/roger/template/helpers/capture.rb +1 -1
- data/lib/roger/version.rb +1 -1
- data/test/project/layouts/partial.html.erb +1 -0
- data/test/project/layouts/partial_with_block.html.erb +1 -0
- data/test/unit/renderer/renderer_layout_test.rb +40 -0
- data/test/unit/template/template_base_test.rb +20 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92478f7482bcbb5fa9dfe14d0a96d092a46e5d78
|
4
|
+
data.tar.gz: b6f75c7d2deb4c7d3d5afb2fd5c5ea3bd2e9c22d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a7ca884f0897b455af8b81c1eff91fe0066ac71b3d3f89bd302b533fdf2b7dc7ba1ba8f69a1472727327fc9434b328f11ad92b6fb98d7ef8a0d7f836469ad43
|
7
|
+
data.tar.gz: 560301778c4892fbbeb5040a7c1e00162f1012af0395202e4f0c92c52c2401bb7e920f9df40e9bdda9b9af4c212bebd4fd02c0339256fbf1c94000b57a08bb1c
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -36,7 +36,7 @@ module Roger
|
|
36
36
|
|
37
37
|
# rubocop:disable Lint/Eval
|
38
38
|
def capture(&block)
|
39
|
-
unless
|
39
|
+
unless Thread.current[:tilt_current_template].is_a?(Tilt::ERBTemplate)
|
40
40
|
err = "content_for works only with ERB Templates"
|
41
41
|
err += "(was: #{template.current_tilt_template.inspect})"
|
42
42
|
fail ArgumentError, err
|
data/lib/roger/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %><%= partial "test/simple" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %><% partial "test/yield" do %>PARTIAL<% end %>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Generators register themself on the CLI module
|
3
|
+
require "test_helper"
|
4
|
+
require "./lib/roger/renderer.rb"
|
5
|
+
|
6
|
+
module Roger
|
7
|
+
# Roger template tests
|
8
|
+
class RendererBaseTest < ::Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@base = Pathname.new(File.dirname(__FILE__) + "/../../project")
|
11
|
+
@config = {
|
12
|
+
partials_path: @base + "partials",
|
13
|
+
layouts_path: @base + "layouts",
|
14
|
+
source_path: @base + "html/test.html.erb"
|
15
|
+
}
|
16
|
+
@template_path = @base + "html"
|
17
|
+
|
18
|
+
@renderer = Renderer.new({}, @config)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_basic_layout
|
22
|
+
template = "---\nlayout: \"yield\"\n---\nTEMPLATE"
|
23
|
+
assert_equal "TEMPLATE", render_erb_template(template)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_layout_with_partial
|
27
|
+
template = "---\nlayout: \"partial\"\n---\nTEMPLATE"
|
28
|
+
assert_equal "TEMPLATEERB", render_erb_template(template)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_layout_with_block_partial
|
32
|
+
template = "---\nlayout: \"partial_with_block\"\n---\nTEMPLATE"
|
33
|
+
assert_equal "TEMPLATEB-PARTIAL-A", render_erb_template(template)
|
34
|
+
end
|
35
|
+
|
36
|
+
def render_erb_template(template)
|
37
|
+
@renderer.render(@base + "html/layouts/test.html.erb", source: template)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -25,5 +25,25 @@ module Roger
|
|
25
25
|
template = Template.new("<%= yield %>", {}, source_path: "test.erb")
|
26
26
|
assert_equal "inner", template.render { "inner" }
|
27
27
|
end
|
28
|
+
|
29
|
+
def test_data
|
30
|
+
template = Template.new("---\nkey: value\n---\ndata", {}, source_path: "test.erb")
|
31
|
+
assert_equal "value", template.data[:key]
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_faulty_data
|
35
|
+
template = Template.new("---\nkey value\n---\ndata", {}, source_path: "test.erb")
|
36
|
+
assert_equal({}, template.data)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_strip_data_block
|
40
|
+
template = Template.new("---\nkey: value\n---\ndata", {}, source_path: "test.erb")
|
41
|
+
assert_equal "data", template.render
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_strip_faulty_data_block
|
45
|
+
template = Template.new("---\nkey value\n---\ndata", {}, source_path: "test.erb")
|
46
|
+
assert_equal "data", template.render
|
47
|
+
end
|
28
48
|
end
|
29
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flurin Egger
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-10-
|
13
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -286,6 +286,8 @@ files:
|
|
286
286
|
- test/project/html/renderer/recursive.html.erb
|
287
287
|
- test/project/html/static/non-relative.html.erb
|
288
288
|
- test/project/html/static/relative.html.erb
|
289
|
+
- test/project/layouts/partial.html.erb
|
290
|
+
- test/project/layouts/partial_with_block.html.erb
|
289
291
|
- test/project/layouts/test.html.erb
|
290
292
|
- test/project/layouts/yield.html.erb
|
291
293
|
- test/project/lib/generators/test.rb
|
@@ -333,6 +335,7 @@ files:
|
|
333
335
|
- test/unit/renderer/renderer_base_test.rb
|
334
336
|
- test/unit/renderer/renderer_content_for_test.rb
|
335
337
|
- test/unit/renderer/renderer_helper_test.rb
|
338
|
+
- test/unit/renderer/renderer_layout_test.rb
|
336
339
|
- test/unit/renderer/renderer_partial_test.rb
|
337
340
|
- test/unit/resolver_test.rb
|
338
341
|
- test/unit/server_test.rb
|
@@ -392,6 +395,8 @@ test_files:
|
|
392
395
|
- test/project/html/renderer/recursive.html.erb
|
393
396
|
- test/project/html/static/non-relative.html.erb
|
394
397
|
- test/project/html/static/relative.html.erb
|
398
|
+
- test/project/layouts/partial.html.erb
|
399
|
+
- test/project/layouts/partial_with_block.html.erb
|
395
400
|
- test/project/layouts/test.html.erb
|
396
401
|
- test/project/layouts/yield.html.erb
|
397
402
|
- test/project/lib/generators/test.rb
|
@@ -439,6 +444,7 @@ test_files:
|
|
439
444
|
- test/unit/renderer/renderer_base_test.rb
|
440
445
|
- test/unit/renderer/renderer_content_for_test.rb
|
441
446
|
- test/unit/renderer/renderer_helper_test.rb
|
447
|
+
- test/unit/renderer/renderer_layout_test.rb
|
442
448
|
- test/unit/renderer/renderer_partial_test.rb
|
443
449
|
- test/unit/resolver_test.rb
|
444
450
|
- test/unit/server_test.rb
|