010ae74e6b76ece4b1096d45de33d94feef8d910
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
6 CKEDITOR
.htmlParser
.basicWriter
= CKEDITOR
.tools
.createClass(
19 * Writes the tag opening part for a opener tag.
20 * @param {String} tagName The element name for this tag.
21 * @param {Object} attributes The attributes defined for this tag. The
22 * attributes could be used to inspect the tag.
25 * writer.openTag( 'p', { class : 'MyClass', id : 'MyId' } );
27 openTag : function( tagName
, attributes
)
29 this._
.output
.push( '<', tagName
);
33 * Writes the tag closing part for a opener tag.
34 * @param {String} tagName The element name for this tag.
35 * @param {Boolean} isSelfClose Indicates that this is a self-closing tag,
39 * writer.openTagClose( 'p', false );
42 * writer.openTagClose( 'br', true );
44 openTagClose : function( tagName
, isSelfClose
)
47 this._
.output
.push( ' />' );
49 this._
.output
.push( '>' );
53 * Writes an attribute. This function should be called after opening the
54 * tag with {@link #openTagClose}.
55 * @param {String} attName The attribute name.
56 * @param {String} attValue The attribute value.
58 * // Writes ' class="MyClass"'.
59 * writer.attribute( 'class', 'MyClass' );
61 attribute : function( attName
, attValue
)
63 // Browsers don't always escape special character in attribute values. (#4683, #4719).
64 if ( typeof attValue
== 'string' )
65 attValue
= CKEDITOR
.tools
.htmlEncodeAttr( attValue
);
67 this._
.output
.push( ' ', attName
, '="', attValue
, '"' );
71 * Writes a closer tag.
72 * @param {String} tagName The element name for this tag.
74 * // Writes "</p>".
75 * writer.closeTag( 'p' );
77 closeTag : function( tagName
)
79 this._
.output
.push( '</', tagName
, '>' );
84 * @param {String} text The text value
86 * // Writes "Hello Word".
87 * writer.text( 'Hello Word' );
89 text : function( text
)
91 this._
.output
.push( text
);
96 * @param {String} comment The comment text.
98 * // Writes "<!-- My comment -->".
99 * writer.comment( ' My comment ' );
101 comment : function( comment
)
103 this._
.output
.push( '<!--', comment
, '-->' );
107 * Writes any kind of data to the ouput.
109 * writer.write( 'This is an <b>example</b>.' );
111 write : function( data
)
113 this._
.output
.push( data
);
117 * Empties the current output buffer.
124 this._
.indent
= false;
128 * Empties the current output buffer.
129 * @param {Boolean} reset Indicates that the {@link reset} function is to
130 * be automatically called after retrieving the HTML.
131 * @returns {String} The HTML written to the writer so far.
133 * var html = writer.getHtml();
135 getHtml : function( reset
)
137 var html
= this._
.output
.join( '' );