Module: Erubis::PhpGenerator

Includes:
Generator
Included in:
Ephp, Erubis::PI::Ephp
Defined in:
lib/erubis/engine/ephp.rb

Instance Attribute Summary

Attributes included from Generator

#escapefunc

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Generator

#escaped_expr

Class Method Details

.supported_propertiesObject

:nodoc:



17
18
19
# File 'lib/erubis/engine/ephp.rb', line 17

def self.supported_properties()  # :nodoc:
  return []
end

Instance Method Details

#add_expr_debug(src, code) ⇒ Object



47
48
49
50
51
# File 'lib/erubis/engine/ephp.rb', line 47

def add_expr_debug(src, code)
  code.strip!
  s = code.gsub(/\'/, "\\'")
  src << "<?php error_log('*** debug: #{s}='.(#{code}), 0); ?>"
end

#add_expr_escaped(src, code) ⇒ Object



43
44
45
# File 'lib/erubis/engine/ephp.rb', line 43

def add_expr_escaped(src, code)
  add_expr_literal(src, escaped_expr(code))
end

#add_expr_literal(src, code) ⇒ Object



38
39
40
41
# File 'lib/erubis/engine/ephp.rb', line 38

def add_expr_literal(src, code)
  code.strip!
  src << "<?php echo #{code}; ?>"
end

#add_postamble(src) ⇒ Object



64
65
66
# File 'lib/erubis/engine/ephp.rb', line 64

def add_postamble(src)
  # empty
end

#add_preamble(src) ⇒ Object



26
27
28
# File 'lib/erubis/engine/ephp.rb', line 26

def add_preamble(src)
  # empty
end

#add_stmt(src, code) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'lib/erubis/engine/ephp.rb', line 53

def add_stmt(src, code)
  src << "<?php"
  src << " " if code[0] != ?\ #
  if code[-1] == ?\n
    code.chomp!
    src << code << "?>\n"
  else
    src << code << "?>"
  end
end

#add_text(src, text) ⇒ Object



34
35
36
# File 'lib/erubis/engine/ephp.rb', line 34

def add_text(src, text)
  src << escape_text(text)
end

#escape_text(text) ⇒ Object



30
31
32
# File 'lib/erubis/engine/ephp.rb', line 30

def escape_text(text)
  return text.gsub!(/<\?xml\b/, '<<?php ?>?xml') || text
end

#init_generator(properties = {}) ⇒ Object



21
22
23
24
# File 'lib/erubis/engine/ephp.rb', line 21

def init_generator(properties={})
  super
  @escapefunc ||= 'htmlspecialchars'
end