module Erubis::Converter
convert
Attributes
escape[RW]
postamble[RW]
preamble[RW]
Public Instance Methods
convert(input)
click to toggle source
convert input string into target language
# File lib/erubis/converter.rb, line 33 def convert(input) codebuf = "" # or [] @preamble.nil? ? add_preamble(codebuf) : (@preamble && (codebuf << @preamble)) convert_input(codebuf, input) @postamble.nil? ? add_postamble(codebuf) : (@postamble && (codebuf << @postamble)) @_proc = nil # clear cached proc object return codebuf # or codebuf.join() end
init_converter(properties={})
click to toggle source
# File lib/erubis/converter.rb, line 26 def init_converter(properties={}) @preamble = properties[:preamble] @postamble = properties[:postamble] @escape = properties[:escape] end
Protected Instance Methods
convert_input(codebuf, input)
click to toggle source
(abstract) convert input to code
# File lib/erubis/converter.rb, line 77 def convert_input(codebuf, input) not_implemented end
detect_spaces_at_bol(text, is_bol)
click to toggle source
detect spaces at beginning of line
# File lib/erubis/converter.rb, line 47 def detect_spaces_at_bol(text, is_bol) lspace = nil if text.empty? lspace = "" if is_bol elsif text[-1] == ?\n lspace = "" else rindex = text.rindex(?\n) if rindex s = text[rindex+1..-1] if s =~ /\A[ \t]*\z/ lspace = s #text = text[0..rindex] text[rindex+1..-1] = '' end else if is_bol && text =~ /\A[ \t]*\z/ #lspace = text #text = nil lspace = text.dup text[0..-1] = '' end end end return lspace end