Module Kwartz::StatementHelper
In: kwartz/converter.rb

Methods

Public Instance methods

[Source]

# File kwartz/converter.rb, line 389
    def add_foreach_stmts(stmt_list, handler_arg, foreach_code, endforeach_code,
                          content_only, counter, toggle, init_code, incr_code, toggle_code)
      arg = handler_arg
      stmt_list << stag_stmt(arg)                   if content_only
      start_code.split(/\n/).each do |code|
        stmt_list << NativeStatement.new(code, kind)
      end if start_code
      stmt_list << stag_stmt(arg)                   if !content_only
      stmt_list.concat(arg.cont_stmts)
      stmt_list << etag_stmt(arg)                   if !content_only
      end_code.split(/\n/).each do |code|
        stmt_list << NativeStatement.new(code, kind)
      end
      stmt_list << etag_stmt(arg)                   if content_only
    end

[Source]

# File kwartz/converter.rb, line 362
    def add_native_code(stmt_list, code, kind)
      if code.is_a?(String)
        stmt_list << NativeStatement.new(code, kind)
      elsif code.is_a?(Array)
        stmt_list.concat(code.collect {|line| NativeStatement.new(line, kind)})
      end
    end

[Source]

# File kwartz/converter.rb, line 406
    def add_native_expr_with_default(stmt_list, handler_arg,
                                     expr_code, flag_escape,
                                     if_code, else_code, endif_code)
      arg = handler_arg
      stmt_list << stag_stmt(arg)
      stmt_list << NativeStatement.new_without_newline(if_code, :if)
      stmt_list << PrintStatement.new([ NativeExpression.new(expr_code, flag_escape) ])
      stmt_list << NativeStatement.new_without_newline(else_code, :else)
      stmt_list.concat(arg.cont_stmts)
      stmt_list << NativeStatement.new_without_newline(endif_code, :else)
      stmt_list << etag_stmt(arg)
    end

create array of String and NativeExpression for PrintStatement

[Source]

# File kwartz/converter.rb, line 290
    def build_print_args(taginfo, attr_info, append_exprs)
      return [] if taginfo.tagname.nil?
      #if taginfo.tagname.nil?
      #  if (!attr_info || attr_info.empty?) && (!append_exprs || append_exprs.empty?)
      #    return []
      #  else
      #    taginfo.tagname = 'span'
      #  end
      #end
      unless attr_info || append_exprs
        return [taginfo.tag_text]
      end
      args = []
      t = taginfo
      sb = "#{t.head_space}<#{t.is_etag ? '/' : ''}#{t.tagname}"
      attr_info.each do |space, aname, avalue|
        sb << "#{space}#{aname}=\""
        if avalue.is_a?(NativeExpression)
          args << sb     # TextExpression.new(sb)
          args << avalue
          sb = ''
        else
          sb << avalue
        end
        sb << '"'
      end if attr_info
      if append_exprs && !append_exprs.empty?
        unless sb.empty?
          args << sb     # TextExpression.new(sb)
          sb = ''
        end
        args.concat(append_exprs)
      end
      sb << "#{t.extra_space}#{t.is_empty ? '/' : ''}>#{t.tail_space}"
      args << sb         # TextExpression.new(sb)
      return args
    end

create PrintStatement for NativeExpression

[Source]

# File kwartz/converter.rb, line 337
    def build_print_expr_stmt(native_expr, stag_info, etag_info)
      head_space = (stag_info || etag_info).head_space
      tail_space = (etag_info || stag_info).tail_space
      args = []
      args << head_space if head_space    # TexExpression.new(head_space)
      args << native_expr
      args << tail_space if tail_space    # TextExpression.new(tail_space)
      return PrintStatement.new(args)
    end

create PrintStatement for TagInfo

[Source]

# File kwartz/converter.rb, line 330
    def build_print_stmt(taginfo, attr_info, append_exprs)
      args = build_print_args(taginfo, attr_info, append_exprs)
      return PrintStatement.new(args)
    end

create print statement from text

[Source]

# File kwartz/converter.rb, line 283
    def create_text_print_stmt(text)
      return PrintStatement.new([text])
      #return PritnStatement.new([TextExpression.new(text)])
    end

build print statemetn of end-tag

[Source]

# File kwartz/converter.rb, line 356
    def etag_stmt(handler_arg)
      arg = handler_arg
      return build_print_stmt(arg.etag_info, nil, nil)
    end

build print statement of start-tag

[Source]

# File kwartz/converter.rb, line 349
    def stag_stmt(handler_arg)
      arg = handler_arg
      return build_print_stmt(arg.stag_info, arg.attr_info, arg.append_exprs)
    end

[Source]

# File kwartz/converter.rb, line 380
    def wrap_content_with_native_stmt(stmt_list, handler_arg, start_code, end_code, kind=nil)
      stmt_list << stag_stmt(handler_arg)
      add_native_code(stmt_list, start_code, kind)
      stmt_list.concat(handler_arg.cont_stmts)
      add_native_code(stmt_list, end_code, kind)
      stmt_list << etag_stmt(handler_arg)
    end

[Source]

# File kwartz/converter.rb, line 371
    def wrap_element_with_native_stmt(stmt_list, handler_arg, start_code, end_code, kind=nil)
      add_native_code(stmt_list, start_code, kind)
      stmt_list << stag_stmt(handler_arg)
      stmt_list.concat(handler_arg.cont_stmts)
      stmt_list << etag_stmt(handler_arg)
      add_native_code(stmt_list, end_code, kind)
    end

[Validate]