Processing Instructions (PI) converter for XML. this class converts ’’ and ’${…}’ notation.
# File lib/erubis/converter.rb, line 224 224: def convert(input) 225: code = super(input) 226: return @header || @footer ? "#{@header}#{code}#{@footer}" : code 227: end
# File lib/erubis/converter.rb, line 215 215: def init_converter(properties={}) 216: super(properties) 217: @trim = properties.fetch(:trim, true) 218: @pi = properties[:pi] if properties[:pi] 219: @embchar = properties[:embchar] || '@' 220: @pattern = properties[:pattern] 221: @pattern = '<% %>' if @pattern.nil? #|| @pattern == true 222: end
# File lib/erubis/converter.rb, line 231 231: def convert_input(codebuf, input) 232: unless @regexp 233: @pi ||= 'e' 234: ch = Regexp.escape(@embchar) 235: if @pattern 236: left, right = @pattern.split(' ') 237: @regexp = /<\?#{@pi}(?:-(\w+))?(\s.*?)\?>([ \t]*\r?\n)?|#{ch}(!*)?\{(.*?)\}#{ch}|#{left}(=+)(.*?)#{right}/ 238: else 239: @regexp = /<\?#{@pi}(?:-(\w+))?(\s.*?)\?>([ \t]*\r?\n)?|#{ch}(!*)?\{(.*?)\}#{ch}/ 240: end 241: end 242: # 243: is_bol = true 244: pos = 0 245: input.scan(@regexp) do |pi_arg, stmt, rspace, 246: indicator1, expr1, indicator2, expr2| 247: match = Regexp.last_match 248: len = match.begin(0) - pos 249: text = input[pos, len] 250: pos = match.end(0) 251: lspace = stmt ? detect_spaces_at_bol(text, is_bol) : nil 252: is_bol = stmt && rspace ? true : false 253: add_text(codebuf, text) # unless text.empty? 254: # 255: if stmt 256: if @trim && lspace && rspace 257: add_pi_stmt(codebuf, "#{lspace}#{stmt}#{rspace}", pi_arg) 258: else 259: add_text(codebuf, lspace) if lspace 260: add_pi_stmt(codebuf, stmt, pi_arg) 261: add_text(codebuf, rspace) if rspace 262: end 263: else 264: add_pi_expr(codebuf, expr1 || expr2, indicator1 || indicator2) 265: end 266: end 267: #rest = $' || input # ruby1.8 268: rest = pos == 0 ? input : input[pos..1] # ruby1.9 269: add_text(codebuf, rest) 270: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.