Sha256: d9e9d0702a5a7296216b01202df65ceed7837acbd284e3527f8200134005af32

Contents?: true

Size: 1.49 KB

Versions: 26

Compression:

Stored size: 1.49 KB

Contents

require 'processors/base_processor'

#Base Processor for templates/views
class TemplateProcessor < BaseProcessor

  #Initializes template information.
  def initialize tracker, template_name, called_from = nil, file_name = nil
    super(tracker) 
    @current_template = { :name => template_name,
                          :caller => called_from,
                          :partial => template_name.to_s[0,1] == "_",
                          :outputs => [],
                          :src => nil, #set in Processor
                          :type => nil, #set in Processor
                          :file => file_name } 
    if called_from
      template_name = (template_name.to_s + "." + called_from.to_s).to_sym
    end

    tracker.templates[template_name] = @current_template

    @inside_concat = false
    self.warn_on_default = false
  end

  #Process the template Sexp.
  def process exp
    begin
      super
    rescue Exception => e
      except = e.exception("Error when processing #{@current_template[:name]}: #{e.message}")
      except.set_backtrace(e.backtrace)
      raise except
    end
  end

  #Ignore initial variable assignment
  def process_lasgn exp
    if exp[1] == :_erbout and exp[2].node_type == :str  #ignore
      ignore
    elsif exp[1] == :_buf and exp[2].node_type == :str
      ignore
    else
      exp[2] = process exp[2]
      exp
    end
  end

  #Adds output to the list of outputs.
  def process_output exp
    process exp[1]
    @current_template[:outputs] << exp
    exp
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
brakeman-min-0.5.2 lib/processors/template_processor.rb
brakeman-0.5.2 lib/processors/template_processor.rb
brakeman-min-0.5.1 lib/processors/template_processor.rb
brakeman-0.5.1 lib/processors/template_processor.rb
brakeman-min-0.5.0 lib/processors/template_processor.rb
brakeman-0.5.0 lib/processors/template_processor.rb
brakeman-0.4.1 lib/processors/template_processor.rb
brakeman-min-0.4.1 lib/processors/template_processor.rb
brakeman-min-0.4.0 lib/processors/template_processor.rb
brakeman-0.4.0 lib/processors/template_processor.rb
brakeman-min-0.3.2 lib/processors/template_processor.rb
brakeman-0.3.2 lib/processors/template_processor.rb
brakeman-min-0.3.1 lib/processors/template_processor.rb
brakeman-0.3.1 lib/processors/template_processor.rb
brakeman-min-0.3.0 lib/processors/template_processor.rb
brakeman-0.3.0 lib/processors/template_processor.rb
brakeman-min-0.2.2 lib/processors/template_processor.rb
brakeman-0.2.2 lib/processors/template_processor.rb
brakeman-min-0.2.1 lib/processors/template_processor.rb
brakeman-0.2.1 lib/processors/template_processor.rb