lib/miam/template_helper.rb in miam-0.2.4 vs lib/miam/template_helper.rb in miam-0.2.5.beta1

- old
+ new

@@ -1,8 +1,10 @@ module Miam module TemplateHelper def include_template(template_name, context = {}) + @template_name = template_name + @caller = caller[0] tmplt = @context.templates[template_name.to_s] unless tmplt raise "Template `#{template_name}` is not defined" end @@ -13,8 +15,17 @@ @context = context_orig end def context @context + end + + def required(*args) + missing_args = args.map(&:to_s) - @context.keys.map(&:to_s) + unless missing_args.empty? + ex = ArgumentError.new("Missing arguments: [#{missing_args.join(", ")}] in template: '#{@template_name}'") + ex.set_backtrace(@caller) + raise ex + end end end end