Class: ZERB
Constant Summary
collapse
- @@template_stack =
++++++++++++++++++++++++++++++ @@template_stack @@gdata
Array.new
Constants inherited
from Zarchitect
Zarchitect::ASSETDIR, Zarchitect::ASSETSDIR, Zarchitect::BUILDIR, Zarchitect::CONFIGDIR, Zarchitect::DEBUGSDIR, Zarchitect::DRAFTDIR, Zarchitect::FILEDIR, Zarchitect::FILESDIR, Zarchitect::HTMLDIR, Zarchitect::LAYOUTDIR, Zarchitect::NODEDIR, Zarchitect::SHARESDIR, Zarchitect::VERSION
Instance Method Summary
collapse
Methods inherited from Zarchitect
#main, #rss
Constructor Details
#initialize(template) ⇒ ZERB
Returns a new instance of ZERB.
16
17
18
19
|
# File 'lib/zarchitect/zerb.rb', line 16
def initialize(template)
@@template_stack.push(template)
@template = template
end
|
Instance Method Details
#handle_data(hash) ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/zarchitect/zerb.rb', line 37
def handle_data(hash)
@data = hash
hash.each do |k,v|
if instance_variable_defined?("@#{k}")
GPI.print "Error: Data key invalid #{k} - already defined"
GPI.quit
end
instance_variable_set("@#{k}", v)
end
end
|
#output ⇒ Object
32
33
34
35
|
# File 'lib/zarchitect/zerb.rb', line 32
def output
@@template_stack.pop
@out
end
|
#prepare ⇒ Object
21
22
23
24
25
|
# File 'lib/zarchitect/zerb.rb', line 21
def prepare
GPI.print "ZERB preparing #{@template}",
GPI::CLU.check_option('v')
@renderer = ERB.new(File.open(@template) { |f| f.read})
end
|
#render ⇒ Object
28
29
30
|
# File 'lib/zarchitect/zerb.rb', line 28
def render
@out = @renderer.result(binding())
end
|