dry-view 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +15 -0
- data/Gemfile +1 -0
- data/lib/dry/view/layout.rb +8 -4
- data/lib/dry/view/renderer.rb +1 -1
- data/lib/dry/view/version.rb +1 -1
- data/spec/integration/view_spec.rb +7 -9
- data/spec/spec_helper.rb +7 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3b4e09263f41a0b0972c1270fa32e5911ad028b
|
4
|
+
data.tar.gz: b7787ff1b20f6fae7c4c67461ac7e2c1cf51e498
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d79d4a61109cce4b3885d5c0bba544563ebd8d253465acb33c1022f62a61f369de0c972a2ea6657d1d6fb76841a4e4e5baaea7d5df16864e6f2f0b43e54ae881
|
7
|
+
data.tar.gz: 84a995bd47ddd4909cc8658bb2af52dc369b96b9c37d4f74add32a8fc21ce682837fbb7226c16aab164c0389197b5d9183b3bc82009ed608c7fb2d6c9002c3dc
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# 0.1.1 / 2016-07-07
|
2
|
+
|
3
|
+
### Changed
|
4
|
+
|
5
|
+
- Configure default template encoding to be UTF-8, fixing some issues with template rendering on deployed sites (gotar)
|
6
|
+
|
7
|
+
# 0.1.0 / 2016-03-28
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
– `Dry::View::Layout` supports multiple view template formats. Configure format/engine pairs (e.g. `{html: :slim, text: :erb}`) on the `formats` setting. The first format becomes the default. Request specific formats when calling the view, e.g. `my_view.call(format: :text)`.
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
– Extracted from rodakase and renamed to dry-view. `Rodakase::View` is now `Dry::View`.
|
data/Gemfile
CHANGED
data/lib/dry/view/layout.rb
CHANGED
@@ -12,8 +12,6 @@ module Dry
|
|
12
12
|
class Layout
|
13
13
|
include Dry::Equalizer(:config)
|
14
14
|
|
15
|
-
Scope = Struct.new(:page)
|
16
|
-
|
17
15
|
DEFAULT_DIR = 'layouts'.freeze
|
18
16
|
|
19
17
|
extend Dry::Configurable
|
@@ -59,8 +57,10 @@ module Dry
|
|
59
57
|
def call(options = {})
|
60
58
|
renderer = self.class.renderer(options.fetch(:format, default_format))
|
61
59
|
|
60
|
+
template_content = renderer.(template_path, template_scope(options, renderer))
|
61
|
+
|
62
62
|
renderer.(layout_path, layout_scope(options, renderer)) do
|
63
|
-
|
63
|
+
template_content
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -94,7 +94,11 @@ module Dry
|
|
94
94
|
private
|
95
95
|
|
96
96
|
def layout_scope(options, renderer)
|
97
|
-
|
97
|
+
part_hash = {
|
98
|
+
page: layout_part(:page, renderer, options.fetch(:scope, scope))
|
99
|
+
}
|
100
|
+
|
101
|
+
part(layout_dir, renderer, part_hash)
|
98
102
|
end
|
99
103
|
|
100
104
|
def template_scope(options, renderer)
|
data/lib/dry/view/renderer.rb
CHANGED
data/lib/dry/view/version.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
RSpec.describe 'dry-view' do
|
2
2
|
let(:view_class) do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
Class.new(Dry::View::Layout) do
|
4
|
+
configure do |config|
|
5
|
+
config.root = SPEC_ROOT.join('fixtures/templates')
|
6
|
+
config.name = 'app'
|
7
|
+
config.template = 'users'
|
8
|
+
config.formats = {html: :slim, txt: :erb}
|
9
|
+
end
|
10
10
|
end
|
11
|
-
|
12
|
-
klass
|
13
11
|
end
|
14
12
|
|
15
13
|
let(:scope) do
|
data/spec/spec_helper.rb
CHANGED
@@ -9,9 +9,15 @@ rescue LoadError; end
|
|
9
9
|
|
10
10
|
SPEC_ROOT = Pathname(__FILE__).dirname
|
11
11
|
|
12
|
-
require '
|
12
|
+
require 'erb'
|
13
13
|
require 'slim'
|
14
14
|
|
15
|
+
# Prefer plain ERB processor rather than erubis (which has problems on JRuby)
|
16
|
+
require 'tilt'
|
17
|
+
Tilt.register 'erb', Tilt::ERBTemplate
|
18
|
+
|
19
|
+
require 'dry-view'
|
20
|
+
|
15
21
|
RSpec.configure do |config|
|
16
22
|
config.disable_monkey_patching!
|
17
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inflecto
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- ".gitignore"
|
133
133
|
- ".rspec"
|
134
134
|
- ".travis.yml"
|
135
|
+
- CHANGELOG.md
|
135
136
|
- Gemfile
|
136
137
|
- LICENSE.md
|
137
138
|
- README.md
|