Skip to content

Commit

Permalink
Merge branch 't/11102'
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Dec 30, 2013
2 parents ac648cc + acd5db3 commit ac305ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Expand Up @@ -3,6 +3,9 @@ CKEditor 4 Changelog

## CKEditor 4.3.2

* [#11102](http://dev.ckeditor.com/ticket/11102): `CKEDITOR.template` improvements:
* added new line character support ([#11102](http://dev.ckeditor.com/ticket/11102)),
* added "\\'" substring support ([#11216](http://dev.ckeditor.com/ticket/11216)).
* [#11121](http://dev.ckeditor.com/ticket/11121): [Firefox] Fixed: High Contrast mode is enabled when editor is loaded in hidden iframe.
* [#11350](http://dev.ckeditor.com/ticket/11350): The default value of [`config.contentsCss`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-contentsCss) is affected by [`CKEDITOR.getUrl`](http://docs.ckeditor.com/#!/api/CKEDITOR-method-getUrl).
* [#11097](http://dev.ckeditor.com/ticket/11097): Improved the [Autogrow](http://ckeditor.com/addon/autogrow) plugin performance when dealing with very big tables.
Expand Down
21 changes: 14 additions & 7 deletions core/template.js
Expand Up @@ -9,7 +9,12 @@
*/

( function() {
var cache = {};
var cache = {},
rePlaceholder = /{([^}]+)}/g,
reQuote = /'/g,
reEscapableChars = /([\\'])/g,
reNewLine = /\n/g,
reCarriageReturn = /\r/g;

/**
* Lightweight template used to build the output string from variables.
Expand All @@ -34,12 +39,14 @@
this.output = cache[ source ];
else {
var fn = source
// Escape all quotation marks (").
.replace( /'/g, "\\'" )
// Inject the template keys replacement.
.replace( /{([^}]+)}/g, function( m, key ) {
return "',data['" + key + "']==undefined?'{" + key + "}':data['" + key + "'],'";
} );
// 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 + "'],'";
} );

fn = "return buffer?buffer.push('" + fn + "'):['" + fn + "'].join('');";
this.output = cache[ source ] = Function( 'data', 'buffer', fn );
Expand Down

0 comments on commit ac305ed

Please sign in to comment.