Module Erubis::BiPatternEnhancer
In: erubis/enhancer.rb

enable to use other embedded expression pattern (default is ’\[= =\]’).

notice! this is an experimental. spec may change in the future.

ex.

  input = <<END
  <% for item in list %>
    <%= item %> : <%== item %>
    [= item =] : [== item =]
  <% end %>
  END

  class BiPatternEruby
    include BiPatternEnhancer
  end
  eruby = BiPatternEruby.new(input, :bipattern=>'\[= =\]')
  list = ['<a>', 'b&b', '"c"']
  print eruby.result(binding())

  ## output
    <a> : &lt;a&gt;
    <a> : &lt;a&gt;
    b&b : b&amp;b
    b&b : b&amp;b
    "c" : &quot;c&quot;
    "c" : &quot;c&quot;

this is language independent.

Methods

add_text   new  

Public Class methods

[Source]

# File erubis/enhancer.rb, line 350
    def initialize(input, properties={})
      self.bipattern = properties[:bipattern]    # or '\$\{ \}'
      super
    end

Public Instance methods

[Source]

# File erubis/enhancer.rb, line 362
    def add_text(src, text)
      return unless text
      text.scan(@bipattern_regexp) do |txt, indicator, code|
        super(src, txt)
        add_expr(src, code, '=' + indicator)
      end
      rest = $' || text
      super(src, rest)
    end

[Validate]