Class: ActionView::PathResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/w2tags/rails_hook-3.x.rb

Constant Summary collapse

W2TAGS =
W2Tags::Parser.new('rails')

Instance Method Summary collapse

Instance Method Details

#query(path, exts, formats) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/w2tags/rails_hook-3.x.rb', line 8

def query(path, exts, formats)
  query = File.join(@path, path)

  exts.each do |ext|
    query << '{' << ext.map {|e| e && ".#{e}" }.join(',') << ',}'
  end

  query.gsub!(/\{\.html,/, "{.html,.text.html,")
  query.gsub!(/\{\.text,/, "{.text,.text.plain,")

  Dir[query].reject { |p| File.directory?(p) }.map do |p|
    handler, format = extract_handler_and_format(p, formats)
    W2TAGS.parse_file(p.gsub(/\.erb$/,'.w2erb'),true,true)
    contents = File.open(p, "rb") {|io| io.read }

    Template.new(contents, File.expand_path(p), handler,
      :virtual_path => path, :format => format)
  end
end