XML : How to render plain XML properties with Roar::Decorator

I am trying to render a plain XML output within a Roar::Decorator. For some reason it is not possible to get unescaped output.

I have this class:

  class GetShopProductsRequest < OpenStruct      def data_filter      xml_s = []      xml_s << "<Filter>"      xml_s << "  <FilterName>#{self.filter_name}</FilterName>"      xml_s << "  <FilterValues>"      xml_s << "    <FilterValue>#{self.filter_value}</FilterValue>"      xml_s << "  </FilterValues>"      xml_s << "</Filter>"        xml_s.join("\n")    end    end    

and the following representer:

  class GetShopProductsRequestRepresenter < RequestRepresenter      property :data_filter, as: :DataFilter    end    

which inherits from Roar::Decorator and includes Roar::XML

However, when I create my representer instance with

  GetShopProductsRequestRepresenter.new(GetShopProductsRequest.new(filter_value => 123, :filter_name => "test"))    

and create the XML Output .to_xml the output is

  <DataFilter>&lt;Filter&gt;         &lt;FilterName&gt;bla&lt;/FilterName&gt;         &lt;FilterValues&gt;           &lt;FilterValue&gt;test&lt;/FilterValue&gt;         &lt;/FilterValues&gt;       &lt;/Filter&gt;</DataFilter>    

I tried to use html_safe at serveral spots in the code but nothing changed the result.

No comments:

Post a Comment