module InlineERB::ClassMethods

Constants

SNIPPET_RE

Public Instance Methods

new(*args, &block) click to toggle source
Calls superclass method
# File lib/embed_view/railtie.rb, line 5
def new(*args, &block)
  source     = args[0]
  identifier = args[1]
  while (matches = source.scan(SNIPPET_RE)).any? do
    #puts matches.inspect
    #puts "-----------------------------------------#{matches.size}--"
    matches.each do |(a, b, c)|
      path = File.expand_path(File.join(File.dirname(identifier), b.strip))
      Rails.logger.debug "  embed_view: #{b.strip}"
      source.gsub!(Regexp.new("<%=.*embed_view.*#{a}#{b}#{c}.*%>"), File.binread(path))
      identifier = path
    end
  end
  #binding.pry
  # puts source
  # puts "--------------------------"
  # puts "--------------------------"
  # puts "--------------------------"
  args[0] = source
  super(*args, &block)
end