Added XML::Element#inner_text=
This method can be used to more easily set the text of an element, without having to manually muck around with XML::Text instances.
This commit is contained in:
1 parent
cfbdf1bdb1
commit
6cb2d54875
2 files changed
+31
No files matched your search
@@ -145,6 +145,19 @@ module Oga
|
||||
return nodes
|
||||
end
|
||||
|
||||
##
|
||||
# Sets the inner text of the current element to the given String.
|
||||
#
|
||||
# @param [String] text
|
||||
#
|
||||
def inner_text=(text)
|
||||
children.each do |child|
|
||||
child.remove if child.is_a?(Text)
|
||||
end
|
||||
|
||||
children << XML::Text.new(:text => text)
|
||||
end
|
||||
|
||||
##
|
||||
# Converts the element and its child elements to XML.
|
||||
#
|
||||
|
||||
Reference in new issue
Block a user