Sha256: 6d8c0fe61b90d9f657bcc043b49a866df6fc7bbbf9a816f09d0fed3eb5bc0103

Contents?: true

Size: 920 Bytes

Versions: 3

Compression:

Stored size: 920 Bytes

Contents

#!/usr/bin/env ruby

macro "|xml|" do
	begin
		valid_xml_element
		max_parameters 1
	rescue Exception => e
		if @node[:fallback] then
			macro_error "Unknown macro '#{@node[:element]}'"
		else
			raise
		end
	end
	name = @node[:element]
 	if Glyph["options.xml_blacklist"] && name.to_s.in?(Glyph['options.xml_blacklist']) then
		""
	else
		attributes # evaluate attributes
		xml_attributes = @node.children.select{|node| node.is_a?(Glyph::AttributeNode)}.
			map do |e| 
			if valid_xml_attribute(e[:name]) then
				%|#{e[:name]}="#{e[:value]}"|
			else
				nil
			end
			end.compact.join(" ")
			xml_attributes = " "+xml_attributes unless xml_attributes.blank?
			end_first_tag = param(0) ? ">" : ""
			end_tag = param(0) ? "</#{name}>" : " />"
			contents = (@node.param(0)&0) && (@node.param(0)&0)[:element] ? "\n#{param(0)}\n" : param(0)
			%{<#{name}#{xml_attributes}#{end_first_tag}#{contents}#{end_tag}}
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
glyph-0.4.2 macros/xml.rb
glyph-0.4.1 macros/xml.rb
glyph-0.4.0 macros/xml.rb