| Module | Erubis::Converter |
| In: |
lib/erubis/converter.rb
|
| escape | [RW] | |
| postamble | [RW] | |
| preamble | [RW] |
convert input string into target language
# File lib/erubis/converter.rb, line 34
34: def convert(input)
35: codebuf = "" # or []
36: @preamble.nil? ? add_preamble(codebuf) : (@preamble && (codebuf << @preamble))
37: convert_input(codebuf, input)
38: @postamble.nil? ? add_postamble(codebuf) : (@postamble && (codebuf << @postamble))
39: @_proc = nil # clear cached proc object
40: return codebuf # or codebuf.join()
41: end
# File lib/erubis/converter.rb, line 27
27: def init_converter(properties={})
28: @preamble = properties[:preamble]
29: @postamble = properties[:postamble]
30: @escape = properties[:escape]
31: end
detect spaces at beginning of line
# File lib/erubis/converter.rb, line 48
48: def detect_spaces_at_bol(text, is_bol)
49: lspace = nil
50: if text.empty?
51: lspace = "" if is_bol
52: elsif text[-1] == ?\n
53: lspace = ""
54: else
55: rindex = text.rindex(?\n)
56: if rindex
57: s = text[rindex+1..-1]
58: if s =~ /\A[ \t]*\z/
59: lspace = s
60: #text = text[0..rindex]
61: text[rindex+1..-1] = ''
62: end
63: else
64: if is_bol && text =~ /\A[ \t]*\z/
65: #lspace = text
66: #text = nil
67: lspace = text.dup
68: text[0..-1] = ''
69: end
70: end
71: end
72: return lspace
73: end