Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use Builder instead of Haml in writer, as Haml 6+ removes support f…
…or custom tags. * Create sub-class of Builder::XmlMarkup to be able to eliminate surrounding whitespace for XML Literals. * Use QNames everywhere instead of CURIEs. * Updates for Ruby 2.6 compatibility. * Remove obsolete Nokogiri Hacks and Haml Templates. * Capture Standard output in writer tests.
- Loading branch information
Showing
16 changed files
with
483 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Extend builder to allow for better control of whitespace in XML Literals | ||
|
||
require 'builder' | ||
|
||
module Builder | ||
# Extends XmlMarkup#tag! to better control whitespace when adding content from a block | ||
# | ||
class RdfXml < Builder::XmlMarkup | ||
# Create a tag named +sym+. Other than the first argument which | ||
# is the tag name, the arguments are the same as the tags | ||
# implemented via <tt>method_missing</tt>. | ||
# | ||
# @see https://github.com/jimweirich/builder/blob/master/lib/builder/xmlbase.rb | ||
def tag!(sym, *args, &block) | ||
text = nil | ||
attrs = args.last.is_a?(::Hash) ? args.last : {} | ||
return super unless block && attrs[:no_whitespace] | ||
attrs.delete(:no_whitespace) | ||
|
||
sym = "#{sym}:#{args.shift}".to_sym if args.first.kind_of?(::Symbol) | ||
|
||
args.each do |arg| | ||
case arg | ||
when ::Hash | ||
attrs.merge!(arg) | ||
when nil | ||
attrs.merge!({:nil => true}) if explicit_nil_handling? | ||
else | ||
text ||= '' | ||
text << arg.to_s | ||
end | ||
end | ||
|
||
unless text.nil? | ||
::Kernel::raise ::ArgumentError, | ||
"XmlMarkup cannot mix a text argument with a block" | ||
end | ||
|
||
# Indent | ||
_indent | ||
#unless @indent == 0 || @level == 0 | ||
# text!(" " * (@level * @indent)) | ||
#end | ||
|
||
_start_tag(sym, attrs) | ||
begin | ||
_nested_structures(block) | ||
ensure | ||
_end_tag(sym) | ||
_newline | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.