Class: Dress::Maker
- Inherits:
-
Object
show all
- Defined in:
- lib/dress.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
166
167
168
169
170
171
|
# File 'lib/dress.rb', line 166
def method_missing(method,*args,&block)
Nokogiri.make {
d = self.send(method,*args,&block)
}
end
|
Class Method Details
.layout(name = nil, &block) ⇒ Object
134
135
136
|
# File 'lib/dress.rb', line 134
def layout(name=nil,&block)
layout_defs[name] = block
end
|
.layouts ⇒ Object
129
130
131
132
|
# File 'lib/dress.rb', line 129
def layouts
layout_defs.keys
end
|
.render(page, *args, &block) ⇒ Object
145
146
147
|
# File 'lib/dress.rb', line 145
def render(page,*args,&block)
self.new.render(page,*args,&block)
end
|
.render_with(layout, page, *args, &block) ⇒ Object
149
150
151
|
# File 'lib/dress.rb', line 149
def render_with(layout,page,*args,&block)
self.new.render_with(layout,page,*args,&block)
end
|
.with(name, page, *args, &block) ⇒ Object
138
139
140
141
142
143
|
# File 'lib/dress.rb', line 138
def with(name,page,*args,&block)
content = self.new.send(page,*args,&block)
l = layout(name).clone
l.at("content").replace(content)
l
end
|
Instance Method Details
#render(page, *args, &block) ⇒ Object
154
155
156
157
|
# File 'lib/dress.rb', line 154
def render(page,*args,&block)
render_with(nil,page,*args,&block)
end
|
#render_with(layout, page, *args, &block) ⇒ Object
159
160
161
162
163
164
|
# File 'lib/dress.rb', line 159
def render_with(layout,page,*args,&block)
content = self.send(page,*args,&block)
l = self.instance_eval(&self.class.layout_defs[layout])
l.at("content").replace(content)
l
end
|