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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03a55b8f70f9a2c483db8b54a34cc46470b67824
4
- data.tar.gz: 8bb2990860563bfd3efc8fcc42f2d08a2642b743
3
+ metadata.gz: f3b4e09263f41a0b0972c1270fa32e5911ad028b
4
+ data.tar.gz: b7787ff1b20f6fae7c4c67461ac7e2c1cf51e498
5
5
  SHA512:
6
- metadata.gz: 407e38a1b4c40c3cb95146218771f0099a61345abededc7cde29ecbfbcf1448288208786ef35cd463dcfe8c2d532c44fb57dc66790f62b53b42ba97b5726825e
7
- data.tar.gz: 2c4c61cb1325de92fab40a23ede167b93be155f0e0981ff5ef5f51faee9126748756f3a03000962b136132936e78a29746a21371e08095b008a130d716968a63
6
+ metadata.gz: d79d4a61109cce4b3885d5c0bba544563ebd8d253465acb33c1022f62a61f369de0c972a2ea6657d1d6fb76841a4e4e5baaea7d5df16864e6f2f0b43e54ae881
7
+ data.tar.gz: 84a995bd47ddd4909cc8658bb2af52dc369b96b9c37d4f74add32a8fc21ce682837fbb7226c16aab164c0389197b5d9183b3bc82009ed608c7fb2d6c9002c3dc
data/.travis.yml CHANGED
@@ -9,7 +9,7 @@ rvm:
9
9
  - 2.1
10
10
  - 2.2
11
11
  - 2.3.0
12
- - rbx-2
12
+ - rbx
13
13
  - jruby-9000
14
14
  - ruby-head
15
15
  - jruby-head
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
@@ -4,6 +4,7 @@ gemspec
4
4
 
5
5
  group :test do
6
6
  gem 'byebug', platform: :mri
7
+ gem 'rack', '>= 1.0.0', '<= 2.0.0'
7
8
  gem 'slim'
8
9
 
9
10
  gem 'codeclimate-test-reporter', platform: :rbx
@@ -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
- renderer.(template_path, template_scope(options, renderer))
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
- Scope.new(layout_part(:page, renderer, options.fetch(:scope, scope)))
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)
@@ -37,7 +37,7 @@ module Dry
37
37
  end
38
38
 
39
39
  def tilt(path)
40
- tilts.fetch(path) { tilts[path] = Tilt[engine].new(path) }
40
+ tilts.fetch(path) { tilts[path] = Tilt[engine].new(path, nil, default_encoding: "utf-8") }
41
41
  end
42
42
 
43
43
  def lookup(name)
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module View
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
@@ -1,15 +1,13 @@
1
1
  RSpec.describe 'dry-view' do
2
2
  let(:view_class) do
3
- klass = Class.new(Dry::View::Layout)
4
-
5
- klass.configure do |config|
6
- config.root = SPEC_ROOT.join('fixtures/templates')
7
- config.name = 'app'
8
- config.template = 'users'
9
- config.formats = {html: :slim, txt: :erb}
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 'dry-view'
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.0
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-03-28 00:00:00.000000000 Z
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