Class: Flex::Template::Tags
- Inherits:
-
Array
- Object
- Array
- Flex::Template::Tags
- Defined in:
- lib/flex/template/tags.rb
Constant Summary collapse
- TAG_REGEXP =
/<<\s*([\w\.]+)\s*(?:=([^>]*))*>>/
Instance Method Summary collapse
- #partial_and_tag_names ⇒ Object
- #stringify(structure) ⇒ Object
-
#variables ⇒ Object
tag variables are the defaults defined with the tag a variable could be optional, and the default could be nil.
Instance Method Details
#partial_and_tag_names ⇒ Object
33 34 35 |
# File 'lib/flex/template/tags.rb', line 33 def partial_and_tag_names map(&:name).partition{|n| n.to_s =~ /^_/} end |
#stringify(structure) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/flex/template/tags.rb', line 23 def stringify(structure) structure.inspect.gsub(/(?:"#{TAG_REGEXP}"|#{TAG_REGEXP})/) do match = $& match =~ TAG_REGEXP t = Tag.new($1, $2) push t unless find{|i| i.name == t.name} (match !~ /^"/) ? "\#{vars.get_prunable(:'#{t.name}')}" : "vars.get_prunable(:'#{t.name}')" end end |
#variables ⇒ Object
tag variables are the defaults defined with the tag a variable could be optional, and the default could be nil
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/flex/template/tags.rb', line 9 def variables tag_variables = Vars.new each do |t| if t.default || t.optional if t.name =~ /\./ # set default for nested var tag_variables.store_nested(t.name, t.default) else tag_variables[t.name] = t.default end end end tag_variables end |