lib/slacker.rb
def render(template_name, options = {})
      template_file_path = get_sql_template_path(template_name)

      if !File.exists?(template_file_path)
        raise "File #{template_file_path} does not exist"
      end

      begin
        sql_template_path_stack.push(File.dirname(template_file_path))
        result = render_text(IO.read(template_file_path, {:mode => 'r:BOM|UTF-8'}), options)
      rescue => detail
        # Report errors in the template
        if detail.backtrace[0] =~ /^\(erb\)/
          raise "Template error in #{template_name}:\n#{detail.backtrace[0]} : #{detail.message}\n"
        else
          raise detail
        end
      ensure
        sql_template_path_stack.pop
      end

      result
    end
# Render a template file and return the result
Render a template file and return the result
Render a template file and return the result
def render(template_name, options = {})
      template_file_path = get_sql_template_path(template_name)
      if !File.exists?(template_file_path)
        raise "File #{template_file_path} does not exist"
      end
      begin
        sql_template_path_stack.push(File.dirname(template_file_path))
        result = render_text(IO.read(template_file_path, {:mode => 'r:BOM|UTF-8'}), options)
      rescue => detail
        if detail.backtrace[0] =~ /^\(erb\)/
          raise "Template error in #{template_name}:\n#{detail.backtrace[0]} : #{detail.message}\n"
        else
          raise detail
        end
      ensure
        sql_template_path_stack.pop
      end
      result
    end
def render ( template_name , options = { } ) template_file_path = get_sql_template_path ( template_name ) if ! File . exists? ( template_file_path ) raise "File #{template_file_path} does not exist" end begin sql_template_path_stack . push ( File . dirname ( template_file_path ) ) result = render_text ( IO . read ( template_file_path , { :mode => 'r:BOM|UTF-8' } ) , options ) rescue => detail if detail . backtrace [ 0 ] =~ / ^ \( erb \) / raise "Template error in #{template_name}:\n#{detail.backtrace[0]} : #{detail.message}\n" else raise detail end ensure sql_template_path_stack . pop end result end
Render a template file and return the result
Render a template file and return the result
# Report errors in the template
template_name
options