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 +4 -4
- data/bin/dimples +1 -1
- data/lib/dimples/renderer.rb +7 -8
- data/lib/dimples/version.rb +1 -1
- metadata +2 -3
- data/lib/dimples/renderable.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d65b80a2178346477e6764b9427935e6efa0b29c
|
4
|
+
data.tar.gz: 0a0ac665aa58a094ec72e3ab88d524d0896fd348
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45c629d7a0fc140cf20edd35ab60384edad125db510c20875dc16a6eef9ac7c6d7d300986ee70f507d618dd5544e79daa6c0bbb8507ad025cd5ac628a5ec2be0
|
7
|
+
data.tar.gz: 208f30c81208efb99991d78480c9e6284541a8c93ac068ec28a22a6164f60843c2d6bf5a67c8393081ebb93e8e8843e9cf6ec74950ff9a42d2bdfacf8fd43539
|
data/bin/dimples
CHANGED
data/lib/dimples/renderer.rb
CHANGED
@@ -10,19 +10,18 @@ module Dimples
|
|
10
10
|
callback = proc { @source.contents }
|
11
11
|
|
12
12
|
@engine = if @source.path
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
24
|
-
|
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
|
data/lib/dimples/version.rb
CHANGED
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.
|
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-
|
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
|
data/lib/dimples/renderable.rb
DELETED
@@ -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
|