Module | Erubis::SimplifyEnhancer
In: | erubis/enhancer.rb

get convert faster, but spaces around ’<%…%>’ are not trimmed.

this is language-independent.

### Methods

convert

### Constants

SIMPLE_REGEXP | = | /<%(=+|\#)?(.*?)-?%>/m |  | DEFAULT_REGEXP = /(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m

### Public Instance methods

convert(input)

[Source]

    # File erubis/enhancer.rb, line 342
        def convert(input)
          src = ""
          add_preamble(src)
          #regexp = pattern_regexp(@pattern)
          pos = 0
          input.scan(SIMPLE_REGEXP) do |indicator, code|
            match = Regexp.last_match
            index = match.begin(0)
            text  = input[pos, index - pos]
            pos   = match.end(0)
            add_text(src, text)
            if !indicator              # <% %>
              add_stmt(src, code)
            elsif indicator[0] == ?\#  # <%# %>
              n = code.count("\n")
              add_stmt(src, "\n" * n)
            else                       # <%= %>
              add_expr(src, code, indicator)
            end
          end
          #rest = $' || input                      # ruby1.8
          rest = pos == 0 ? input : input[pos..-1]  # ruby1.9
          add_text(src, rest)
          add_postamble(src)
          return src
        end

[Validate]