Class: Orange::Middleware::Template
- Inherits:
-
Base
show all
- Defined in:
- lib/orange-core/middleware/template.rb
Instance Method Summary
collapse
Methods inherited from Base
#call, #initialize, #inspect, #orange, #pass, #recapture
Instance Method Details
#needs_wrapped?(packet) ⇒ Boolean
25
26
27
28
|
# File 'lib/orange-core/middleware/template.rb', line 25
def needs_wrapped?(packet)
return false if packet.request.xhr? && !packet['template.enable'] packet['template.file'] && !packet['template.disable']
end
|
#packet_call(packet) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/orange-core/middleware/template.rb', line 13
def packet_call(packet)
packet['template.file'] = orange.template_for packet
status, , content = pass packet
if needs_wrapped?(packet)
content = wrap(packet, content)
packet[:content] = content.first
orange.fire(:wrapped, packet)
end
orange.fire(:after_wrap, packet)
packet.finish
end
|
#wrap(packet, content = false) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/orange-core/middleware/template.rb', line 30
def wrap(packet, content = false)
content = packet.content unless content
content = content.join
content = orange[:parser].haml(packet['template.file'], packet, :wrapped_content => content, :template => true) do
content
end
[content]
end
|