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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce8d31486e669021fd7b9d454d097d1f6a274051
4
- data.tar.gz: 55b801c6151d73af405f94fdc3ea2a939aa29bc4
3
+ metadata.gz: 8a470c7d6cf09d23fb9d8e77d03057e488a6137c
4
+ data.tar.gz: 21967f188873fff1b8c62cd29f038cc4e08c941e
5
5
  SHA512:
6
- metadata.gz: 0833fdd497dacd4365422097155bf43f396a90c8a5a04707dceae7a1d611d3e4ce2c32eb60bdbe3fa1bb4d8859ddadda700b3d75c2de9b16228ba59e035e92cb
7
- data.tar.gz: 4787df6f8c547e6a09808e49fb2389a734466e08ff2f0099bb85a558d7f020e5780c139ad440c6a86d18282819aa57401197e9a64075f38324b1c25cb014538b
6
+ metadata.gz: f9273f7fb916292828a84cda65c49bad99f0316202de8be5b1e8f768519741678db642fe401dfda27fe18ad20305b6a9f8f005b869b2bbd4e86bd086543dd559
7
+ data.tar.gz: 70bbd4ca3937888d76d10b84541184d59423c0e30c9367f18171b773fbae34a97aa37a01e9ce9362a313dc620ae44f430c84c5af89b2fee1fbc9b6dc168d20f0
@@ -116,12 +116,16 @@ module Theme
116
116
  end
117
117
 
118
118
  def component name, options = {}, &block
119
- theme_components[name].set_locals options
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
- req.env[:_theme_components] ||= begin
128
+ @_theme_components ||= begin
125
129
  components = {}
126
130
 
127
131
  Theme.config.components.each do |name, klass|
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Theme
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-01 00:00:00.000000000 Z
11
+ date: 2014-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt