cutaneous 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/cutaneous.gemspec +2 -2
- data/lib/cutaneous/context.rb +6 -9
- data/lib/cutaneous/engine.rb +2 -2
- data/lib/cutaneous.rb +1 -1
- data/test/helper.rb +2 -2
- data/test/test_core.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 012024660b2cd0de6db4295f59f2dd7f627280a4
|
4
|
+
data.tar.gz: ae08e8b3fcdc18c3060104beb02acb4f7e77b3f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 034dc2af99470678f14e0e687c09d946cd52545fc1b515a59c53b379b90d5a01920572db4d28c1bd1d3ae169840b8a9d0aa04ac75e6b94a119c27e6a749ebeaf
|
7
|
+
data.tar.gz: 0e083ff19ecab0be7f48e40a23a2166c188ab41521c0b0c784584369b2a098457f69b34e32bc69fd9733660952d79c5236766b3818823449188a978928df1099
|
data/cutaneous.gemspec
CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
## If your rubyforge_project name is different, then edit it and comment out
|
15
15
|
## the sub! line in the Rakefile
|
16
16
|
s.name = 'cutaneous'
|
17
|
-
s.version = '0.1.
|
18
|
-
s.date = '2013-
|
17
|
+
s.version = '0.1.7'
|
18
|
+
s.date = '2013-11-14'
|
19
19
|
s.rubyforge_project = 'cutaneous'
|
20
20
|
|
21
21
|
## Make sure your summary is short. The description may be as long
|
data/lib/cutaneous/context.rb
CHANGED
@@ -5,10 +5,10 @@ module Cutaneous
|
|
5
5
|
class Context < Delegator
|
6
6
|
attr_accessor :__buf, :__loader, :__target, :__locals
|
7
7
|
|
8
|
-
def initialize(target,
|
8
|
+
def initialize(target, locals = {}, parent_context = nil)
|
9
9
|
super(target)
|
10
10
|
@__target, @__locals = target, {}
|
11
|
-
__update_context(
|
11
|
+
__update_context(locals, parent_context)
|
12
12
|
end
|
13
13
|
|
14
14
|
def __decode_params(params)
|
@@ -25,8 +25,7 @@ module Cutaneous
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def clone(locals = {})
|
28
|
-
context = self.class.new(__target, self)
|
29
|
-
context.__update_with_locals(locals)
|
28
|
+
context = self.class.new(__target, locals, self)
|
30
29
|
context
|
31
30
|
end
|
32
31
|
|
@@ -52,16 +51,14 @@ module Cutaneous
|
|
52
51
|
# Default behaviour is to silently discard errors
|
53
52
|
end
|
54
53
|
|
55
|
-
def __update_context(parent)
|
56
|
-
|
57
|
-
when Hash
|
58
|
-
__update_with_locals(parent)
|
59
|
-
when Cutaneous::Context
|
54
|
+
def __update_context(locals, parent)
|
55
|
+
unless parent.nil?
|
60
56
|
parent.instance_variables.reject { |var| /^@__/o === var.to_s }.each do |variable|
|
61
57
|
instance_variable_set(variable, parent.instance_variable_get(variable))
|
62
58
|
end
|
63
59
|
__update_with_locals(parent.__locals) if parent.respond_to?(:__locals)
|
64
60
|
end
|
61
|
+
__update_with_locals(locals)
|
65
62
|
end
|
66
63
|
|
67
64
|
# Sets up the local variables and also creates singleton methods on this
|
data/lib/cutaneous/engine.rb
CHANGED
@@ -7,7 +7,7 @@ module Cutaneous
|
|
7
7
|
|
8
8
|
def initialize(template_roots, syntax = Cutaneous::FirstPassSyntax, default_format = "html")
|
9
9
|
@roots = Array(template_roots)
|
10
|
-
@syntax
|
10
|
+
@syntax = syntax
|
11
11
|
@loader_class = FileLoader
|
12
12
|
@default_format = default_format
|
13
13
|
end
|
@@ -24,7 +24,7 @@ module Cutaneous
|
|
24
24
|
|
25
25
|
# Create and cache a file loader on a per-format basis
|
26
26
|
def file_loader(format)
|
27
|
-
file_loader_instance(format.
|
27
|
+
file_loader_instance(format.to_sym).tap do |loader|
|
28
28
|
loader.syntax = @syntax
|
29
29
|
end
|
30
30
|
end
|
data/lib/cutaneous.rb
CHANGED
data/test/helper.rb
CHANGED
data/test/test_core.rb
CHANGED
@@ -217,7 +217,7 @@ describe Cutaneous do
|
|
217
217
|
it "Passes any instance variables & locals between contexts" do
|
218
218
|
context = ContextHash(right: "left")
|
219
219
|
result1 = engine.render("instance", context)
|
220
|
-
context = ContextHash(context)
|
220
|
+
context = ContextHash({}, context)
|
221
221
|
result2 = engine.render("instance", context)
|
222
222
|
result2.must_equal result1
|
223
223
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cutaneous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garry Hill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Cutaneous is the Ruby templating language designed for use with Spontaneous
|
14
14
|
CMS. It has a simple syntax but powerful features such as Djano style template inheritance
|