Class: Rbexy::Nodes::XmlNode
- Inherits:
-
Object
- Object
- Rbexy::Nodes::XmlNode
- Defined in:
- lib/rbexy/nodes.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#members ⇒ Object
readonly
Returns the value of attribute members.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #compile ⇒ Object
- #compile_members ⇒ Object
-
#initialize(name, members, children) ⇒ XmlNode
constructor
A new instance of XmlNode.
Constructor Details
#initialize(name, members, children) ⇒ XmlNode
Returns a new instance of XmlNode.
64 65 66 67 68 |
# File 'lib/rbexy/nodes.rb', line 64 def initialize(name, members, children) @name = name @members = members || [] @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
62 63 64 |
# File 'lib/rbexy/nodes.rb', line 62 def children @children end |
#members ⇒ Object (readonly)
Returns the value of attribute members.
62 63 64 |
# File 'lib/rbexy/nodes.rb', line 62 def members @members end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
62 63 64 |
# File 'lib/rbexy/nodes.rb', line 62 def name @name end |
Instance Method Details
#compile ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rbexy/nodes.rb', line 70 def compile base_tag = "rbexy_tag.#{Util.safe_tag_name(name)}(#{compile_members})" tag = if children.length > 0 [ "#{base_tag} { capture {", children.map(&:compile).map { |c| "@output_buffer << rbexy_prep_output(#{c})" }.join(";"), "} }" ].join else base_tag end + ".html_safe" if Rbexy.configuration.enable_context [ "(", "rbexy_context.push({});", "#{tag}.tap { rbexy_context.pop }", ")" ].join else tag end end |
#compile_members ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rbexy/nodes.rb', line 94 def compile_members members.each_with_object("") do |member, result| case member when ExpressionGroup result << "**#{member.compile}," when SilentNewline result << member.compile else result << "#{member.compile}," end end end |