Module: Erubis::PI::Converter

Includes:
Converter
Included in:
Engine
Defined in:
lib/erubis/converter.rb

Overview

Processing Instructions (PI) converter for XML. this class converts ‘<?rb … ?>’ and ‘$…’ notation.

Instance Attribute Summary collapse

Attributes included from Converter

#escape, #postamble, #preamble

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#piObject

Returns the value of attribute pi.



213
214
215
# File 'lib/erubis/converter.rb', line 213

def pi
  @pi
end

#prefixObject

Returns the value of attribute prefix.



213
214
215
# File 'lib/erubis/converter.rb', line 213

def prefix
  @prefix
end

Class Method Details

.descObject

:nodoc:



200
201
202
# File 'lib/erubis/converter.rb', line 200

def self.desc   # :nodoc:
  "use processing instructions (PI) instead of '<% %>'"
end

.supported_propertiesObject

:nodoc:



204
205
206
207
208
209
210
211
# File 'lib/erubis/converter.rb', line 204

def self.supported_properties    # :nodoc:
  return [
          [:trim,      true,   "trim spaces around <% ... %>"],
          [:pi,        'rb',   "PI (Processing Instrunctions) name"],
          [:embchar,   '@',    "char for embedded expression pattern('@{...}@')"],
          [:pattern,  '<% %>', "embed pattern"],
         ]
end

Instance Method Details

#convert(input) ⇒ Object



224
225
226
227
# File 'lib/erubis/converter.rb', line 224

def convert(input)
  code = super(input)
  return @header || @footer ? "#{@header}#{code}#{@footer}" : code
end

#init_converter(properties = {}) ⇒ Object



215
216
217
218
219
220
221
222
# File 'lib/erubis/converter.rb', line 215

def init_converter(properties={})
  super(properties)
  @trim    = properties.fetch(:trim, true)
  @pi      = properties[:pi] if properties[:pi]
  @embchar = properties[:embchar] || '@'
  @pattern = properties[:pattern]
  @pattern = '<% %>' if @pattern.nil?  #|| @pattern == true
end