Class: Marker::Arguments
- Inherits:
-
RecursiveList
- Object
- Treetop::Runtime::SyntaxNode
- ParseNode
- RecursiveList
- Marker::Arguments
- Defined in:
- lib/marker/templates.rb
Instance Method Summary collapse
-
#block? ⇒ Boolean
returns true if there are any block-style arguments and false if all arguments are inline-style.
- #to_arg_list(format, options = {}) ⇒ Object
- #to_html(options = {}) ⇒ Object
- #to_s(options = {}) ⇒ Object
Methods inherited from RecursiveList
Methods inherited from Treetop::Runtime::SyntaxNode
Instance Method Details
#block? ⇒ Boolean
returns true if there are any block-style arguments and false if all arguments are inline-style
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, = {} ) 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() : "" ) if a.name named_params[a.name.to_s()] = value else pos_params << value end end else to_a.each do |a| next unless a value = ( a.val ? a.val.to_s() : "" ) if a.name named_params[a.name.to_s()] = 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( = {} ) to_a.map { |a| a ? a.to_html() : '' }.join(', ') end |
#to_s(options = {}) ⇒ Object
110 111 112 113 114 |
# File 'lib/marker/templates.rb', line 110 def to_s( = {} ) to_a.map { |a| a ? a.to_s() : '' }.join(', ') end |