lib/tadpole/main.rb in tadpole-0.1.3 vs lib/tadpole/main.rb in tadpole-0.1.4
- old
+ new
@@ -17,10 +17,12 @@
@list
end
end
module Tadpole
+ class MissingTemplateError < ArgumentError; end
+
class << self
attr_accessor :caching
def caching; @caching ||= true end
@@ -33,11 +35,11 @@
end
def template(*path)
path = absolutize_path(*path)
exists = find_matching_template_paths(path)
- raise ArgumentError, "no such template `#{path}'" if exists.empty?
+ raise MissingTemplateError, "no such template `#{path}'" if exists.empty?
create_template(*path)
end
def create_template(*path)
@@ -71,19 +73,21 @@
list << el
total_list = File.join(list)
find_matching_template_paths(total_list).each do |subpath|
submod = create_local_template_mod(subpath, total_list)
mod.send :include, submod
+
+ inherited = submod.inherited_paths
+ inherited.reject! {|path| mod.template_paths.include?(path) }
+ mod.template_paths.unshift(*inherited)
mod.template_paths.unshift(*submod.template_paths)
mod.before_run_filters.push(*submod.before_run_filters)
mod.before_section_filters.push(*submod.before_section_filters)
- inherited.push(*submod.inherited_paths)
end
list
end
-
- mod.template_paths.push(*inherited)
+
mod.template_paths.uniq!
end
def create_template_mod(path)
mod = Module.new
@@ -120,10 +124,10 @@
end
def load_setup_rb(full_path, mod)
setup_file = File.join(full_path, 'setup.rb')
if File.file? setup_file
- mod.module_eval(File.read(setup_file).taint, setup_file)
+ mod.module_eval(File.read(setup_file).taint, setup_file, 1)
end
mod
end
def template_mod_name(full_path)
\ No newline at end of file