From f1ce8a4e95fb908e34f51f00c029a15e4fcd853c Mon Sep 17 00:00:00 2001 From: Patrick Steele-Idem Date: Mon, 5 May 2014 14:48:13 -0600 Subject: [PATCH] Updated compiled output --- README.md | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index cc2c32f11..e2df72c64 100644 --- a/README.md +++ b/README.md @@ -254,11 +254,10 @@ setTimeout(function() { }, 1000); // Render the template to the existing render context: -template - .render({ - name: 'World' - }, - context); +template.render({ + name: 'World' + }, + context); // Write the last chunk synchronously: context.write(' END'); @@ -372,46 +371,46 @@ require('raptor-templates/compiler').compileFile(path, function(err, src) { ### Sample Compiled Template ```javascript -module.exports = function create(helpers) { - var empty = helpers.e, - notEmpty = helpers.ne, - escapeXml = helpers.x, - forEach = helpers.f, - escapeXmlAttr = helpers.xa; +module.exports = function create(__helpers) { + var empty = __helpers.e, + notEmpty = __helpers.ne, + escapeXml = __helpers.x, + forEach = __helpers.f, + escapeXmlAttr = __helpers.xa; return function render(data, context) { - context.w('Hello ') - .w(escapeXml(data.name)) - .w('! '); + context.w(('Hello ') + + (escapeXml(data.name)) + + ('! ')); - if (notEmpty(colors)) { - context.w('')); } else { - context.w('
No colors!
'); + context.w(('
No colors!
')); } }; } ``` -The compiled output is designed to be extremely minifiable. The minified code is shown below: +The compiled output is designed to be both extremely readable and minifiable. The minified code is shown below: ```javascript -module.exports=function(a){var d=a.ne,c=a.x,e=a.f,f=a.xa;return function(a,b){b.w("Hello ").w(c(a.name)).w("! ");d(colors)?(b.w("")):b.w("
No colors!
")}}; +module.exports=function(a){var d=a.ne,c=a.x,e=a.f,f=a.xa;return function(a,b){b.w("Hello "+c(a.name)+"! ");d(a.colors)?(b.w("")):b.w("
No colors!
")}}; ``` -_File size: 193 bytes gzipped (267 bytes uncompressed)_ +_File size: 190 bytes gzipped (251 bytes uncompressed)_ # Language Guide