Class: Dryml::DRYMLBuilder::Erubis

Inherits:
Erubis::Eruby
  • Object
show all
Defined in:
lib/dryml/dryml_builder.rb

Constant Summary collapse

BLOCK_EXPR =
/\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/

Instance Method Summary collapse

Instance Method Details

#add_expr_escaped(src, code) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/dryml/dryml_builder.rb', line 88

def add_expr_escaped(src, code)
  if code =~ BLOCK_EXPR
    src << "self.output_buffer.safe_append= " << code << ";\nself.output_buffer;"
  else
    src << "self.output_buffer.safe_concat((" << code << ").to_s);"
  end
end

#add_expr_literal(src, code) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/dryml/dryml_builder.rb', line 75

def add_expr_literal(src, code)
  if code =~ BLOCK_EXPR
    src << 'self.output_buffer.append= ' << code << ";\nself.output_buffer;"
  else
    src << 'self.output_buffer.append= (' << code << ");\nself.output_buffer;"
  end
end

#add_postamble(src) ⇒ Object



96
97
98
99
# File 'lib/dryml/dryml_builder.rb', line 96

def add_postamble(src)
  # NOTE: we can't just add a 'self.output_buffer' here because this parser
  # is used to compile taglibs which don't HAVE one
end

#add_preamble(src) ⇒ Object



64
65
66
# File 'lib/dryml/dryml_builder.rb', line 64

def add_preamble(src)

end

#add_stmt(src, code) ⇒ Object



83
84
85
86
# File 'lib/dryml/dryml_builder.rb', line 83

def add_stmt(src, code)
  # skip fallback code - it utterly destroys DRYML-generated ERB
  super
end

#add_text(src, text) ⇒ Object



68
69
70
71
# File 'lib/dryml/dryml_builder.rb', line 68

def add_text(src, text)
  return if text.empty?
  src << "self.output_buffer.safe_concat('" << escape_text(text) << "');"
end