roger 1.6.3 → 1.6.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08b47d99903f3d3eead1bac65ee0b5f12d87be52
4
- data.tar.gz: ac530d446306f7891cae517fe062cef21b4af25a
3
+ metadata.gz: 92478f7482bcbb5fa9dfe14d0a96d092a46e5d78
4
+ data.tar.gz: b6f75c7d2deb4c7d3d5afb2fd5c5ea3bd2e9c22d
5
5
  SHA512:
6
- metadata.gz: 25315c6c7e964d202919de443d9d8045379d817737a5cf81b2dcf104ffaffafc128c1b4a183a6d21a03990e1ca7c0ec10586b4c86830ee258c40a381fd151ba3
7
- data.tar.gz: b40b87fe2d800010d15d23fe2104909f3d3998df83a3c17749faa6cba5f2aa8fd77df16ba154da9bdee38c5671b25d64bd9ce4076012b4a5f56a00b4d264d22e
6
+ metadata.gz: 2a7ca884f0897b455af8b81c1eff91fe0066ac71b3d3f89bd302b533fdf2b7dc7ba1ba8f69a1472727327fc9434b328f11ad92b6fb98d7ef8a0d7f836469ad43
7
+ data.tar.gz: 560301778c4892fbbeb5040a7c1e00162f1012af0395202e4f0c92c52c2401bb7e920f9df40e9bdda9b9af4c212bebd4fd02c0339256fbf1c94000b57a08bb1c
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.6.4
4
+ * Fix bug with block partials in layouts by correctly determine the current Tilt template we're rendering.
5
+
3
6
  ## Version 1.6.3
4
7
  * Fix issue with `render_file` screwing up the current_template nesting stack.
5
8
 
data/Gemfile CHANGED
@@ -3,5 +3,6 @@ source "https://rubygems.org"
3
3
  gemspec name: "roger"
4
4
 
5
5
  gem "rake"
6
+ gem "pry"
6
7
  # Only coverage support in CI, CODECLIMATE TOKEN is part of travis.yml
7
8
  gem "codeclimate-test-reporter", group: :test, require: nil if ENV["CODECLIMATE_REPO_TOKEN"]
@@ -36,7 +36,7 @@ module Roger
36
36
 
37
37
  # rubocop:disable Lint/Eval
38
38
  def capture(&block)
39
- unless template.current_tilt_template == Tilt::ERBTemplate
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
@@ -1,4 +1,4 @@
1
1
  # Roger main namespace
2
2
  module Roger
3
- VERSION = "1.6.3"
3
+ VERSION = "1.6.4"
4
4
  end
@@ -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.3
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-05 00:00:00.000000000 Z
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