tinymce.html.Writer

This class is used to write HTML tags out it can be used with the Serializer.

Examples

const writer = tinymce.html.Writer({ indent: true });
writer.start('node', { attr: 'value' });
writer.end('node');
console.log(writer.getContent());

Summary

Methods

Name Summary Defined by

cdata()

Writes a cdata node, such as <![CDATA[data]]>.

Writer

comment()

Writes a comment node, such as <!-- Comment -->.

Writer

doctype()

Writes a doctype node, such as <!DOCTYPE data>.

Writer

end()

Writes an end element, such as </p>.

Writer

getContent()

Returns the contents that was serialized.

Writer

pi()

Writes a processing instruction (PI) node, such as <?xml attr="value" ?>.

Writer

reset()

Resets the internal buffer. For example, if one wants to reuse the writer.

Writer

start()

Writes a start element, such as <p id="a">.

Writer

text()

Writes a text node.

Writer

Methods

cdata()

cdata(text: String)

Writes a cdata node, such as <![CDATA[data]]>.

Parameters

  • text (String) - String to write out inside the cdata.


comment()

comment(text: String)

Writes a comment node, such as <!-- Comment -->.

Parameters

  • text (String) - String to write out inside the comment.


doctype()

doctype(text: String)

Writes a doctype node, such as <!DOCTYPE data>.

Parameters

  • text (String) - String to write out inside the doctype.


end()

end(name: String)

Writes an end element, such as </p>.

Parameters

  • name (String) - Name of the element.


getContent()

getContent(): String

Returns the contents that was serialized.

Return value

  • String - HTML contents that got written down.


pi()

pi(name: String, text: String)

Writes a processing instruction (PI) node, such as <?xml attr="value" ?>.

Parameters

  • name (String) - Name of the pi.

  • text (String) - String to write out inside the pi.


reset()

reset()

Resets the internal buffer. For example, if one wants to reuse the writer.


start()

start(name: String, attrs: Array, empty: Boolean)

Writes a start element, such as <p id="a">.

Parameters

  • name (String) - Name of the element.

  • attrs (Array) - Optional array of objects containing an attribute name and value, or undefined if the element has no attributes.

  • empty (Boolean) - Optional empty state if the tag should serialize as a void element. For example: <img />


text()

text(text: String, raw: Boolean)

Writes a text node.

Parameters

  • text (String) - String to write out.

  • raw (Boolean) - Optional raw state. If true, the contents won’t get encoded.