- // Try to read from the cache.
- if ( cache[ source ] )
- this.output = cache[ source ];
- else {
- var fn = source
- // Escape chars like slash "\" or single quote "'".
- .replace( reEscapableChars, '\\$1' )
- .replace( reNewLine, '\\n' )
- .replace( reCarriageReturn, '\\r' )
- // Inject the template keys replacement.
- .replace( rePlaceholder, function( m, key ) {
- return "',data['" + key + "']==undefined?'{" + key + "}':data['" + key + "'],'";
- } );
+ /**
+ * Processes the template, filling its variables with the provided data.
+ *
+ * @method
+ * @member CKEDITOR.template
+ * @param {Object} data An object containing properties whose values will be
+ * used to fill the template variables. The property names must match the
+ * template variables names. Variables without matching properties will be
+ * kept untouched.
+ * @param {Array} [buffer] An array that the output data will be pushed into.
+ * The number of entries appended to the array is unknown.
+ * @returns {String/Number} If `buffer` has not been provided, the processed
+ * template output data; otherwise the new length of `buffer`.
+ */
+ CKEDITOR.template.prototype.output = function( data, buffer ) {
+ var output = this.source.replace( rePlaceholder, function( fullMatch, dataKey ) {
+ return data[ dataKey ] !== undefined ? data[ dataKey ] : fullMatch;
+ } );