From 0fd7035a886320a9ec7c11bfd643a99b163944b1 Mon Sep 17 00:00:00 2001 From: Gibheer Date: Fri, 23 Nov 2012 21:28:05 +0100 Subject: cleaned up the commit a bit more --- lib/zero/renderer.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/zero/renderer.rb b/lib/zero/renderer.rb index 3e9f790..31a6e27 100644 --- a/lib/zero/renderer.rb +++ b/lib/zero/renderer.rb @@ -55,14 +55,10 @@ module Zero # the wanted template. def read_template_path! @templates = Hash.new do |hash, key| - subtree = {} - search_files(key).each do |file| - parts = file.split('.') - read_type(parts[2]).each do |type| - subtree[type] = file - end - end - hash[key] = subtree + # TODO this is just ugly + result = [] + search_files(key).each { |file| fill_template_type_map(result, file) } + Hash[result] end self end @@ -73,6 +69,13 @@ module Zero Dir[template_path + template_name + '**/*.*'] end + def fill_template_type_map(dataset, file) + parts = file.split('.') + read_type(parts[2]).each do |type| + dataset << [type, file] + end + end + def read_type(short_notation) to_type_list(type_map[short_notation] || short_notation) end -- cgit v1.2.3-70-g09d2