Class: Kwartz::PhpTranslator

Inherits:
BaseTranslator show all
Includes:
PhpExpressionParser
Defined in:
lib/kwartz/binding/php.rb

Overview

translator for php

Constant Summary collapse

PHP_EMBED_PATTERNS =
[
  '<?php ', ' ?>',                          # statement
  '<?php echo ', '; ?>',                    # expression
  '<?php echo htmlspecialchars(', '); ?>',  # escaped expression
]

Instance Attribute Summary

Attributes inherited from BaseTranslator

#escape, #footer, #header

Instance Method Summary collapse

Methods included from PhpExpressionParser

#parse_expr_str, #parse_expr_str!

Methods inherited from BaseTranslator

#translate, #translate_native_expr, #translate_native_stmt, #translate_print_stmt

Methods inherited from Translator

get_class, register_class, #translate, #translate_native_expr, #translate_native_stmt, #translate_print_stmt

Constructor Details

#initialize(properties = {}) ⇒ PhpTranslator

Returns a new instance of PhpTranslator.



210
211
212
# File 'lib/kwartz/binding/php.rb', line 210

def initialize(properties={})
  super(PHP_EMBED_PATTERNS, properties)
end

Instance Method Details

#translate_string(str) ⇒ Object



215
216
217
218
# File 'lib/kwartz/binding/php.rb', line 215

def translate_string(str)
  str.gsub!(/<\?xml/, '<<?php ?>?xml')
  super(str)
end