Add default value for default templates
If a template has no type specifcation in it's name, then we use 'default' as map name now.
This commit is contained in:
parent
c6623d47df
commit
eccd314e23
|
@ -61,12 +61,16 @@ module Zero
|
|||
search_files.each do |file|
|
||||
parts = file.gsub(/#{template_path}/, '').split('.')
|
||||
@templates[parts[0]] ||= {}
|
||||
|
||||
# Set default value
|
||||
types = 'default'
|
||||
# Overwrite default value, if it's set in template path
|
||||
if parts.count > 2 then
|
||||
read_type(parts[1]).each do |type|
|
||||
@templates[parts[0]][type] = file
|
||||
end
|
||||
else
|
||||
@templates[parts[0]][''] = file
|
||||
types = parts[1]
|
||||
end
|
||||
|
||||
read_type(types).each do |type|
|
||||
@templates[parts[0]][type] = file
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,4 +39,15 @@ describe Zero::Renderer, 'read_template_path!' do
|
|||
|
||||
it_behaves_like 'a template loader'
|
||||
end
|
||||
|
||||
context 'with default template' do
|
||||
let(:file_list) {['foo/welcome/index.erb']}
|
||||
let(:type_map) { {'default' => ['text/html', 'text/xml'] } }
|
||||
let(:result) { {
|
||||
'text/html' => 'foo/welcome/index.erb',
|
||||
'text/xml' => 'foo/welcome/index.erb'
|
||||
} }
|
||||
|
||||
it_behaves_like 'a template loader'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue