Module Kwartz::JstlExpressionParser
In: kwartz/binding/jstl.rb

Methods

Public Instance methods

[Source]

# File kwartz/binding/jstl.rb, line 20
    def parse_expr_str(expr_str, linenum)
      case expr_str
      when /\A(\w+)\z/             # variable
        expr = expr_str
      when /\A(\w+)\.(\w+)\z/      # object.property
        expr = expr_str
      when /\A(\w+)\[('.*?'|".*?"|:\w+)\]\z/   # hash
        key = $2[0] == ?: ? "'#{$2[1..-1]}'" : $2
        expr = "#{$1}[#{key}]"
      when /\A(\w+)\[(\w+)\]\z/    # array or hash
        expr = "#{$1}[#{$2}]"
      else
        raise convert_error("'#{expr_str}': invalid expression.", linenum)
      end
      return expr
    end

[Source]

# File kwartz/binding/jstl.rb, line 38
    def parse_expr_str!(expr_str)
      begin
        return parse_expr_str(expr_str, 0)
      rescue
        return expr_str
      end
    end

[Validate]