class GemHadar::TemplateCompiler
def compile(src, dst)
-
dst
(String
) -- the path to the destination file where the rendered content will be written -
src
(String
) -- the path to the source ERB template file
def compile(src, dst) template = File.read(src) File.open(dst, 'w') do |output| erb = ERB.new(template, nil, '-') erb.filename = src.to_s output.write erb.result binding end end
def initialize(&block)
-
block
(Proc
) -- the block to be evaluated for configuring the template compiler
def initialize(&block) super block_self(&block) @values = {} instance_eval(&block) end
def method_missing(id, *a, &b)
-
(Object)
- the value associated with the method name if retrieving,
Parameters:
-
b
(Proc
) -- the block passed to the method -
a
(Array
) -- the arguments passed to the method -
id
(Symbol
) -- the name of the method being called
def method_missing(id, *a, &b) if a.empty? && id && @values.key?(id) @values[id] elsif a.size == 1 @values[id] = a.first else super end end