Class: Kwartz::PIErubisTranslator
- Inherits:
-
BaseTranslator
- Object
- Translator
- BaseTranslator
- Kwartz::PIErubisTranslator
- Includes:
- RubyExpressionParser
- Defined in:
- lib/kwartz/binding/pierubis.rb
Overview
translator for Erubis
Constant Summary collapse
- PIERUBIS_EMBED_PATTERNS =
[ '<?rb ', ' ?>', # statement '@!{', '}@', # expression '@{', '}@', # escaped expression ]
Instance Attribute Summary
Attributes inherited from BaseTranslator
Instance Method Summary collapse
-
#initialize(properties = {}) ⇒ PIErubisTranslator
constructor
A new instance of PIErubisTranslator.
- #translate_native_expr(expr) ⇒ Object
Methods included from RubyExpressionParser
#parse_expr_str, #parse_expr_str!
Methods inherited from BaseTranslator
#translate, #translate_native_stmt, #translate_print_stmt, #translate_string
Methods inherited from Translator
get_class, register_class, #translate, #translate_native_stmt, #translate_print_stmt, #translate_string
Constructor Details
#initialize(properties = {}) ⇒ PIErubisTranslator
Returns a new instance of PIErubisTranslator.
37 38 39 40 |
# File 'lib/kwartz/binding/pierubis.rb', line 37 def initialize(properties={}) super(PIERUBIS_EMBED_PATTERNS, properties) #@escape = true if @escape == nil end |
Instance Method Details
#translate_native_expr(expr) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/kwartz/binding/pierubis.rb', line 43 def translate_native_expr(expr) assert unless expr.is_a?(NativeExpression) if expr.code.include?(?}) || expr.code.include?(?>) @expr_l, @expr_r, @escape_l, @escape_r = '<%=', '%>', '<%==', '%>' else @expr_l, @expr_r, @escape_l, @escape_r = '@!{', '}@', '@{', '}@' end super(expr) end |