hanami-view 1.1.0.beta1 → 1.1.0.beta2

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
  SHA1:
3
- metadata.gz: '0499a5ecaa4e50c44d7e759ea91747b42332a13c'
4
- data.tar.gz: '066865e74b723cea4e703accc5ea1e45ad76e7ff'
3
+ metadata.gz: 4d032047b20bfbb2f94b4e3b240b104eefacbc96
4
+ data.tar.gz: 82a0620d7476e1b902f0809aeddcb56fa8a166fb
5
5
  SHA512:
6
- metadata.gz: d161a7bac58d23014c570372f456555ad993f5a191e024f4f50a925771bc53ca8181c8d6a3aa1884a1ead62b3b00e0e70a60bbee50319358896b1e9d0638c7e8
7
- data.tar.gz: 46ee3fde97ffa129632ad10209aab687e08b72571a565b4bd384f17c9c1bccc9234e6231b674725090bfc95e94f532492beba5eeebe43c9130c877a74215e83a
6
+ metadata.gz: b69efa59299edd8d6b7f1f04e8c02dfccdd5a827eebc2177a3d8f664d393628bb083332fbcabc45e092485bb6eec85497047366a2222a556a6f0c8d493c3c66f
7
+ data.tar.gz: aca27fde85cb51a9486266e2c904c20e7544eea18f1077529b6aa63f4ec8620ad1c4e31efee198cbd295f10cd88ce6dbebb09a7f53780781455a53ce012ef517
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Hanami::View
2
2
  View layer for Hanami
3
3
 
4
+ ## v1.1.0.beta2 - 2017-10-03
5
+ ### Added
6
+ - [Luca Guidi] Added `Hanami::Layout#local` to safely access locals from layouts
7
+
4
8
  ## v1.1.0.beta1 - 2017-08-11
5
9
  ### Fixed
6
10
  - [yjukaku] Raise `Hanami::View::UnknownRenderTypeError` when an argument different from `:template` or `:partial` is passed to `render`
data/README.md CHANGED
@@ -477,7 +477,7 @@ As per convention, layout templates are located under `Hanami::View.root` or `Ap
477
477
  If we want to render optional contents such as sidebar links or page specific javascripts, we can use `#local`
478
478
  It accepts a key that represents a method that should be available within the rendering context.
479
479
  That context is made of the locals, and the methods that view and layout respond to.
480
- If the context can't dispatch that method, it returns returns a null object (`Hanami::View::Rendering::NullLocal`).
480
+ If the context can't dispatch that method, it returns a null object (`Hanami::View::Rendering::NullLocal`).
481
481
 
482
482
  Given the following layout template.
483
483
 
data/hanami-view.gemspec CHANGED
@@ -20,9 +20,9 @@ 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.1.0.beta1'
23
+ spec.add_runtime_dependency 'hanami-utils', '1.1.0.beta2'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.5'
26
- spec.add_development_dependency 'rspec', '~> 3.5'
27
- spec.add_development_dependency 'rake', '~> 11'
26
+ spec.add_development_dependency 'rspec', '~> 3.6'
27
+ spec.add_development_dependency 'rake', '~> 12'
28
28
  end
data/lib/hanami/layout.rb CHANGED
@@ -139,6 +139,27 @@ module Hanami
139
139
  template.render(@scope, &Proc.new{@rendered})
140
140
  end
141
141
 
142
+ # It tries to invoke a method for the view or a local for the given key.
143
+ # If the lookup fails, it returns a null object.
144
+ #
145
+ # @return [Object,Hanami::View::Rendering::NullLocal] the returning value
146
+ #
147
+ # @since 1.1.0
148
+ #
149
+ # @example Safe method navigation
150
+ # class ApplicationLayout
151
+ # include Hanami::Layout
152
+ #
153
+ # def render_flash
154
+ # return if local(:flash).nil?
155
+ #
156
+ # # ...
157
+ # end
158
+ # end
159
+ def local(key)
160
+ @scope.local(key)
161
+ end
162
+
142
163
  protected
143
164
  # The template for the current format
144
165
  #
@@ -110,7 +110,7 @@ module Hanami
110
110
  # It tries to invoke a method for the view or a local for the given key.
111
111
  # If the lookup fails, it returns a null object.
112
112
  #
113
- # @return [Objeect,Hanami::View::Rendering::NullLocal] the returning value
113
+ # @return [Object,Hanami::View::Rendering::NullLocal] the returning value
114
114
  #
115
115
  # @since 0.7.0
116
116
  #
@@ -131,7 +131,7 @@ module Hanami
131
131
  # It tries to invoke a method for the view or a local for the given key.
132
132
  # If the lookup fails, it returns a null object.
133
133
  #
134
- # @return [Objeect,Hanami::View::Rendering::NullLocal] the returning value
134
+ # @return [Object,Hanami::View::Rendering::NullLocal] the returning value
135
135
  #
136
136
  # @since 0.7.0
137
137
  #
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.1.0.beta1'.freeze
6
+ VERSION = '1.1.0.beta2'.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.1.0.beta1
4
+ version: 1.1.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-11 00:00:00.000000000 Z
11
+ date: 2017-10-03 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.1.0.beta1
39
+ version: 1.1.0.beta2
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.1.0.beta1
46
+ version: 1.1.0.beta2
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -64,28 +64,28 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.5'
67
+ version: '3.6'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.5'
74
+ version: '3.6'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rake
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '11'
81
+ version: '12'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '11'
88
+ version: '12'
89
89
  description: View layer for Hanami
90
90
  email:
91
91
  - me@lucaguidi.com
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  version: 1.3.1
147
147
  requirements: []
148
148
  rubyforge_project:
149
- rubygems_version: 2.6.11
149
+ rubygems_version: 2.6.13
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: View layer for Hanami, with a separation between views and templates