dimples 2.7.0 → 2.7.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: 65b3390259e961fbd65ac4deee280a236440ae2f
4
- data.tar.gz: ff08dd71317105a3020fe348cab53187a7cbff89
3
+ metadata.gz: d65b80a2178346477e6764b9427935e6efa0b29c
4
+ data.tar.gz: 0a0ac665aa58a094ec72e3ab88d524d0896fd348
5
5
  SHA512:
6
- metadata.gz: 873f3072be0e2908e6a07f8fe68c4c304602f37f2397e8714f05ded6affb932b4741adfebe4e56dd5885194c4a744e1ff5848bc21b0f13a837038783b88233d0
7
- data.tar.gz: 8fad5b09ff01ffcb3cfc7beced962a523a53abc81f3058d265bfd633f3872d4b38b70757814875cf64e1e0550e410c771bafe2fad1a211f369ace6a50bf50b79
6
+ metadata.gz: 45c629d7a0fc140cf20edd35ab60384edad125db510c20875dc16a6eef9ac7c6d7d300986ee70f507d618dd5544e79daa6c0bbb8507ad025cd5ac628a5ec2be0
7
+ data.tar.gz: 208f30c81208efb99991d78480c9e6284541a8c93ac068ec28a22a6164f60843c2d6bf5a67c8393081ebb93e8e8843e9cf6ec74950ff9a42d2bdfacf8fd43539
@@ -60,7 +60,7 @@ if Dir.exist?(lib_path)
60
60
  end
61
61
  end
62
62
 
63
- site_klass = config.class_override(:site) || Dimples.Site
63
+ site_klass = config.class_override(:site) || Dimples::Site
64
64
  site = site_klass.new(config)
65
65
 
66
66
  case command.to_sym
@@ -10,19 +10,18 @@ module Dimples
10
10
  callback = proc { @source.contents }
11
11
 
12
12
  @engine = if @source.path
13
- Tilt.new(@source.path, {}, &callback)
14
- else
15
- Tilt::StringTemplate.new(&callback)
16
- end
13
+ Tilt.new(@source.path, {}, &callback)
14
+ else
15
+ Tilt::StringTemplate.new(&callback)
16
+ end
17
17
  end
18
18
 
19
19
  def render(context = {}, body = nil)
20
20
  output = @engine.render(scope(context)) { body }.strip
21
21
  @source.rendered_contents = output
22
22
 
23
- if template = @site.templates[@source.layout]
24
- output = template.render(context, output)
25
- end
23
+ template = @site.templates[@source.layout]
24
+ output = template.render(context, output) unless template.nil?
26
25
 
27
26
  output
28
27
  end
@@ -39,4 +38,4 @@ module Dimples
39
38
  end
40
39
  end
41
40
  end
42
- end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '2.7.0'
4
+ VERSION = '2.7.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-03 00:00:00.000000000 Z
11
+ date: 2017-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -145,7 +145,6 @@ files:
145
145
  - lib/dimples/logger.rb
146
146
  - lib/dimples/page.rb
147
147
  - lib/dimples/post.rb
148
- - lib/dimples/renderable.rb
149
148
  - lib/dimples/renderer.rb
150
149
  - lib/dimples/site.rb
151
150
  - lib/dimples/template.rb
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dimples
4
- # A mixin class that handles rendering via a Tilt template.
5
- module Renderable
6
- def render(context = {}, body = nil, use_layout = true)
7
- output = renderer.render(build_scope(context)) { body }.strip
8
- @rendered_contents = output
9
-
10
- if use_layout && defined?(@layout) && @site.templates[@layout]
11
- output = @site.templates[@layout].render(context, output)
12
- end
13
-
14
- output
15
- rescue => e
16
- error_message = "Unable to render #{@path || self.class} (#{e})"
17
- raise Errors::RenderingError.new, error_message
18
- end
19
-
20
- def build_scope(context)
21
- context[:site] ||= @site
22
- context[:this] ||= self
23
- context[:type] ||= self.class.name.split('::').last.downcase.to_sym
24
-
25
- scope = Object.new
26
-
27
- context.each_pair do |key, value|
28
- scope.instance_variable_set("@#{key}".to_sym, value)
29
- end
30
-
31
- scope
32
- end
33
-
34
- def renderer
35
- callback = proc { contents }
36
-
37
- if @path
38
- extension = File.extname(@path)[1..-1]
39
- options = @site.config['rendering'][extension] || {}
40
-
41
- Tilt.new(@path, options, &callback)
42
- else
43
- Tilt::StringTemplate.new(&callback)
44
- end
45
- end
46
- end
47
- end