lib/lbrt/utils.rb in lbrt-0.1.4 vs lib/lbrt/utils.rb in lbrt-0.1.5
- old
+ new
@@ -31,9 +31,25 @@
instance_eval(File.read(file + '.rb'), file + '.rb')
else
Kernel.require(file)
end
end
+
+ def template(name, &block)
+ @context.templates[name.to_s] = block
+ end
+ end
+
+ module TemplateHelper
+ def include_template(template_name)
+ tmplt = @context.templates[template_name.to_s]
+
+ unless tmplt
+ raise "Template `#{template_name}` is not defined"
+ end
+
+ instance_eval(&tmplt)
+ end
end
module CLIHelper
REGEXP_OPTIONS = [
:target