annotation XMLT::CData

Overview

Marks the property to be serialized as CData or deserialized from CData.

Example

require "xmlt"

struct Multiple
  include XMLT::Serializable

  property number : Int32
  @[XMLT::CData]
  property multiples : Array(Int32)

  def initialize(@number)
    @multiples = (1..10).map &.* @number
  end
end

mult = Multiple.new 4
puts mult.to_xml # =>
# <?xml version="1.0"?>
# <Multiple><number>4</number><![CDATA[[4, 8, 12, 16, 20, 24, 28, 32, 36, 40]]]></Multiple>

Defined in:

annotations.cr