theme 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/theme.rb +6 -2
- data/lib/theme/component.rb +11 -3
- data/lib/theme/version.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: 8a470c7d6cf09d23fb9d8e77d03057e488a6137c
|
4
|
+
data.tar.gz: 21967f188873fff1b8c62cd29f038cc4e08c941e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9273f7fb916292828a84cda65c49bad99f0316202de8be5b1e8f768519741678db642fe401dfda27fe18ad20305b6a9f8f005b869b2bbd4e86bd086543dd559
|
7
|
+
data.tar.gz: 70bbd4ca3937888d76d10b84541184d59423c0e30c9367f18171b773fbae34a97aa37a01e9ce9362a313dc620ae44f430c84c5af89b2fee1fbc9b6dc168d20f0
|
data/lib/theme.rb
CHANGED
@@ -116,12 +116,16 @@ module Theme
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def component name, options = {}, &block
|
119
|
-
theme_components[name]
|
119
|
+
if c = theme_components[name]
|
120
|
+
c.set_locals options
|
121
|
+
else
|
122
|
+
raise "No component called '#{name}' loaded."
|
123
|
+
end
|
120
124
|
end
|
121
125
|
alias :comp :component
|
122
126
|
|
123
127
|
def theme_components
|
124
|
-
|
128
|
+
@_theme_components ||= begin
|
125
129
|
components = {}
|
126
130
|
|
127
131
|
Theme.config.components.each do |name, klass|
|
data/lib/theme/component.rb
CHANGED
@@ -5,7 +5,7 @@ module Theme
|
|
5
5
|
class Component < SimpleDelegator
|
6
6
|
include Theme::Events
|
7
7
|
|
8
|
-
attr_reader :instance, :node, :name
|
8
|
+
attr_reader :instance, :node, :tpl, :name
|
9
9
|
|
10
10
|
def initialize instance = false
|
11
11
|
@instance = instance
|
@@ -51,13 +51,17 @@ module Theme
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
def tpl
|
55
|
+
@tpl ||= OpenStruct.new
|
56
|
+
end
|
57
|
+
|
54
58
|
def clean &block
|
55
59
|
block.call node
|
56
60
|
end
|
57
61
|
alias :setup :clean
|
58
62
|
end
|
59
63
|
|
60
|
-
attr_accessor :node
|
64
|
+
attr_accessor :node, :tpl
|
61
65
|
|
62
66
|
def method_missing method, *args, &block
|
63
67
|
# respond_to?(symbol, include_all=false)
|
@@ -72,6 +76,10 @@ module Theme
|
|
72
76
|
@node ||= self.class.node.clone
|
73
77
|
end
|
74
78
|
|
79
|
+
def tpl
|
80
|
+
@tpl ||= self.class.tpl.clone
|
81
|
+
end
|
82
|
+
|
75
83
|
def render meth = 'display', options = {}, &block
|
76
84
|
if method(meth).parameters.length > 0
|
77
85
|
opts = Hashr.new(options)
|
@@ -96,7 +104,7 @@ module Theme
|
|
96
104
|
end
|
97
105
|
|
98
106
|
|
99
|
-
def set_locals options
|
107
|
+
def set_locals options = {}
|
100
108
|
options.to_h.each do |key, value|
|
101
109
|
(class << self; self; end).send(:attr_accessor, key.to_sym)
|
102
110
|
instance_variable_set("@#{key}", value)
|
data/lib/theme/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|