hanami-view 1.3.0.beta1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f100d8a194322c23df67578b55d851460fcca93fb7c4302f5a73478829ca079
4
- data.tar.gz: f6952d1e8d562ad3de2bdf281a906bf5db7e152f9725769cf92a487ef6ccb44a
3
+ metadata.gz: 4ed81e3efb1ae0ba5ecac568b5be54a37756d25196703320340a2117cd9f80d8
4
+ data.tar.gz: 8938dfb849c7c5acb62810a8f92c6ca91b453466e0f8183b044a7d2e35ea6f42
5
5
  SHA512:
6
- metadata.gz: 2e47e684ee507d0ee4977fc03f8d2808876b0b0d77b954152eafe8900b369ea0a4d3be7ba52e9342791ef14bb3a575ade092e8c65126b0e54ae235693d4abf62
7
- data.tar.gz: ad9e79bf19fe03863ee01ff57e652116b7d218bfa64b5aa25d8b439d9ff87047de19d419a7317c43e7512ffdae89cbf6fe4f0bd7e59996d603cfb2034bece1c9
6
+ metadata.gz: 18693737891ce62ff4d4f7c862ad0fd3096373d630d9b6ca60435ff8e4bbd35b3f565ddf69dc3732255232d991c5a95fe35e2a454a04522d16c0d9bae033a66d
7
+ data.tar.gz: 49a3bfa0efe3b98fff11db2c7af4fcbd65c2dc14e4abc07f7ca843a8eb6524ea1eca493d1cd1dc91fef91f53068258839b380d379edc3efc1a7ea7b9749f1519
@@ -1,11 +1,21 @@
1
1
  # Hanami::View
2
2
  View layer for Hanami
3
3
 
4
+ ## v1.3.0 - 2018-10-24
5
+
4
6
  ## v1.3.0.beta1 - 2018-08-08
5
7
  ### Fixed
6
8
  - [Ferdinand Niedermann] Ensure to set `:disable_escape` option only for Slim and don't let Tilt to emit a warning for other template engines.
7
9
  - [glaszig] Ensure partial rendering to respect `format` overriding
8
10
 
11
+ ## v1.2.1 - 2018-10-16
12
+ ### Added
13
+ - [Luca Guidi] Introduced new, backward compatible, signature to render a layout for testing purposes (eg. `ApplicationLayout.new({ format: :html }, "contents").render`)
14
+
15
+ ### Fixed
16
+ - [Luca Guidi] Ensure layout to be rendered when using HAML 5
17
+ - [Luca Guidi] Ensure to raise `NoMethodError` when an unknown method is invoked by a view/template
18
+
9
19
  ## v1.2.0 - 2018-04-06
10
20
 
11
21
  ## v1.2.0.rc2 - 2018-04-06
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.required_ruby_version = '>= 2.3.0'
21
21
 
22
22
  spec.add_runtime_dependency 'tilt', '~> 2.0', '>= 2.0.1'
23
- spec.add_runtime_dependency 'hanami-utils', '~> 1.3.beta'
23
+ spec.add_runtime_dependency 'hanami-utils', '~> 1.3'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.5'
26
26
  spec.add_development_dependency 'rspec', '~> 3.7'
@@ -2,6 +2,7 @@ require 'hanami/utils/class_attribute'
2
2
  require 'hanami/view/rendering/layout_registry'
3
3
  require 'hanami/view/rendering/layout_scope'
4
4
  require 'hanami/view/rendering/null_layout'
5
+ require 'hanami/view/rendering/null_view'
5
6
 
6
7
  module Hanami
7
8
  # Layout
@@ -116,7 +117,12 @@ module Hanami
116
117
 
117
118
  # Initialize a layout
118
119
  #
119
- # @param scope [Hanami::View::Rendering::Scope] view rendering scope
120
+ # @param scope [Hanami::View::Rendering::Scope,::Hash] view rendering scope.
121
+ # Optionally a scope can be expressed as a Ruby `::Hash`, but it MUST contain
122
+ # the `:format` key, to specify which template to render.
123
+ # @option scope [Symbol] :format the format to render (e.g. `:html`, `:xml`, `:json`)
124
+ # This is mandatory only if a `:Hash` is passed as `scope`.
125
+ #
120
126
  # @param rendered [String] the output of the view rendering process
121
127
  #
122
128
  # @api private
@@ -124,7 +130,19 @@ module Hanami
124
130
  #
125
131
  # @see Hanami::View::Rendering#render
126
132
  def initialize(scope, rendered)
127
- @scope, @rendered = View::Rendering::LayoutScope.new(self, scope), rendered
133
+ # NOTE: This complex data transformation is due to a combination of a bug and the intent of maintaing backward compat (SemVer).
134
+ # See https://github.com/hanami/view/pull/156
135
+ s, r = *case scope
136
+ when ::Hash
137
+ [Hanami::View::Rendering::Scope.new(Hanami::View::Rendering::NullView, scope), rendered]
138
+ when Hanami::View::Template
139
+ [Hanami::View::Rendering::Scope.new(Hanami::View::Rendering::NullView, rendered.merge(format: scope.format)), ""]
140
+ else
141
+ [scope, rendered]
142
+ end
143
+
144
+ @scope = View::Rendering::LayoutScope.new(self, s)
145
+ @rendered = r
128
146
  end
129
147
 
130
148
  # Render the layout
@@ -196,7 +196,7 @@ module Hanami
196
196
  # view = IndexView.new(template, {article: article})
197
197
  #
198
198
  # view.article # => #<Article:0x007fb0bbd3b6e8>
199
- def method_missing(m)
199
+ def method_missing(m, *)
200
200
  @scope.__send__ m
201
201
  end
202
202
  end
@@ -0,0 +1,26 @@
1
+ module Hanami
2
+ module View
3
+ module Rendering
4
+ # Null Object pattern for view
5
+ #
6
+ # It's used when a layout is rendered direcly for testing purposes
7
+ #
8
+ # @api private
9
+ # @since 1.2.1
10
+ class NullView
11
+ # Render the layout template
12
+ #
13
+ # @return [String] an empty string
14
+ #
15
+ # @api private
16
+ # @since 1.2.1
17
+ #
18
+ # @see Hanami::Layout#render
19
+ # @see Hanami::View::Rendering#render
20
+ def render
21
+ ""
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.3.0.beta1'.freeze
6
+ VERSION = '1.3.0'.freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-view
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.beta1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-08 00:00:00.000000000 Z
11
+ date: 2018-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 1.3.beta
39
+ version: '1.3'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 1.3.beta
46
+ version: '1.3'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -113,6 +113,7 @@ files:
113
113
  - lib/hanami/view/rendering/null_layout.rb
114
114
  - lib/hanami/view/rendering/null_local.rb
115
115
  - lib/hanami/view/rendering/null_template.rb
116
+ - lib/hanami/view/rendering/null_view.rb
116
117
  - lib/hanami/view/rendering/options.rb
117
118
  - lib/hanami/view/rendering/partial.rb
118
119
  - lib/hanami/view/rendering/partial_file.rb
@@ -143,9 +144,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
144
  version: 2.3.0
144
145
  required_rubygems_version: !ruby/object:Gem::Requirement
145
146
  requirements:
146
- - - ">"
147
+ - - ">="
147
148
  - !ruby/object:Gem::Version
148
- version: 1.3.1
149
+ version: '0'
149
150
  requirements: []
150
151
  rubyforge_project:
151
152
  rubygems_version: 2.7.7