Class: Marker::Arguments

Inherits:
RecursiveList show all
Defined in:
lib/marker/templates.rb

Instance Method Summary collapse

Methods inherited from RecursiveList

#r, #single?, #to_a

Methods inherited from Treetop::Runtime::SyntaxNode

#present?

Instance Method Details

#block?Boolean

returns true if there are any block-style arguments and false if all arguments are inline-style

Returns:

  • (Boolean)


100
101
102
# File 'lib/marker/templates.rb', line 100

def block?
  to_a.map(&:block?).reduce { |a, b| a or b }
end

#to_arg_list(format, options = {}) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/marker/templates.rb', line 62

def to_arg_list( format, options = {} )
  pos_params = []
  named_params = {}

  case format
  when :raw
    # don't render the text, just return the original value
    # this is needed for special templates, like syntax highlighting
    to_a.each do |a|
      pos_params << a.text_value if a
    end
  when :html
    to_a.each do |a|
      next unless a
      value = ( a.val ? a.val.to_html(options) : "" )
      if a.name
        named_params[a.name.to_s(options)] = value
      else
        pos_params << value
      end
    end
  else
    to_a.each do |a|
      next unless a
      value = ( a.val ? a.val.to_s(options) : "" )
      if a.name
        named_params[a.name.to_s(options)] = value
      else
        pos_params << value
      end
    end
  end

  [pos_params, named_params]
end

#to_html(options = {}) ⇒ Object



104
105
106
107
108
# File 'lib/marker/templates.rb', line 104

def to_html( options = {} )
  to_a.map { |a|
    a ? a.to_html(options) : ''
  }.join(', ')
end

#to_s(options = {}) ⇒ Object



110
111
112
113
114
# File 'lib/marker/templates.rb', line 110

def to_s( options = {} )
  to_a.map { |a|
    a ? a.to_s(options) : ''
  }.join(', ')
end