class BabyErubis::RailsTemplate

Protected Instance Methods

add_expr(src, expr, indicator) click to toggle source
# File lib/baby_erubis/rails.rb, line 38
def add_expr(src, expr, indicator)
  return if !expr || expr.empty?
  l = '('; r = ')'
  l = r = ' ' if expr_has_block(expr)
  if indicator == '='           # escaping
    src << "@output_buffer.append=#{l}#{expr}#{r};"
  else                          # without escaping
    src << "@output_buffer.safe_append=#{l}#{expr}#{r};"
  end
end
add_postamble(src) click to toggle source
# File lib/baby_erubis/rails.rb, line 22
def add_postamble(src)
  src << "@output_buffer.to_s\n"
end
add_preamble(src) click to toggle source
# File lib/baby_erubis/rails.rb, line 18
def add_preamble(src)
  src << "@output_buffer = output_buffer || ActionView::OutputBuffer.new;"
end
add_stmt(src, stmt) click to toggle source
# File lib/baby_erubis/rails.rb, line 33
def add_stmt(src, stmt)
  return if !stmt || stmt.empty?
  src << stmt
end
add_text(src, text) click to toggle source
# File lib/baby_erubis/rails.rb, line 26
def add_text(src, text)
  return if !text || text.empty?
  freeze = @freeze ? '.freeze' : ''
  text.gsub!(/['\\]/, '\\\\\&')
  src << "@output_buffer.safe_append='#{text}'#{freeze};"
end