3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/question_chain/stored_template.rb', line 3
def find_templates(name, prefix, partial, details)
scope = {:name => name, :prefix => prefix}
if formats = details[:formats]
formats = formats.map { |f| f.to_s }
scope.merge!(:format => formats)
end
if locales = details[:locales]
locales = locales.map { |f| f.to_s }
scope. merge!(:locale => locales)
end
StoredTemplate.all(scope).map do |r|
handler = ActionView::Template.handler_class_for_extension(r.handler)
details = { :locale => r.locale, :format => r.format, :partial => r.partial }
ActionView::Template.new(r.source, "Template Generated From DB: #{details.inspect}: Source #{r.source}", handler, details)
end
end
|