1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

bug: Templates are now render in ASCI strings without syntax errors (for update methods)

This commit is contained in:
Ruben S. Montero 2011-07-11 16:49:17 +02:00
parent 2f28688725
commit 75bcc46dd7

@ -214,14 +214,15 @@ module OpenNebula
str_line << n.collect {|n2| str_line << n.collect {|n2|
if n2 && n2.class==REXML::Element if n2 && n2.class==REXML::Element
str = ind_tab + n2.name + "=" str = ""
str += n2.text if n2.text str << ind_tab << n2.name << '='
str << attr_to_str(n2.text) if n2.text
str str
end end
}.compact.join(","+ind_enter) }.compact.join(','+ind_enter)
str_line<<" ]" str_line<<" ]"
else else
str_line<<n.name << "=" << n.text.to_s str_line << n.name << '=' << attr_to_str(n.text.to_s)
end end
str_line str_line
end end
@ -284,6 +285,17 @@ module OpenNebula
hash hash
end end
private
def attr_to_str(attr)
attr.gsub!('"',"\\\"")
if attr.match(/[=,' ']/)
return '"' + attr + '"'
end
return attr
end
end end
########################################################################### ###########################################################################