diff --git a/node_modules/handlebars/README.markdown b/node_modules/handlebars/README.markdown index 56042f4d36..1cba646890 100644 --- a/node_modules/handlebars/README.markdown +++ b/node_modules/handlebars/README.markdown @@ -1,22 +1,32 @@ -[](http://travis-ci.org/wycats/handlebars.js) +[](https://travis-ci.org/wycats/handlebars.js) Handlebars.js ============= -Handlebars.js is an extension to the [Mustache templating language](http://mustache.github.com/) created by Chris Wanstrath. Handlebars.js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be. +Handlebars.js is an extension to the [Mustache templating +language](http://mustache.github.com/) created by Chris Wanstrath. +Handlebars.js and Mustache are both logicless templating languages that +keep the view and the code separated like we all know they should be. -Checkout the official Handlebars docs site at [http://www.handlebarsjs.com](http://www.handlebarsjs.com). +Checkout the official Handlebars docs site at +[http://www.handlebarsjs.com](http://www.handlebarsjs.com). Installing ---------- -Installing Handlebars is easy. Simply [download the package from GitHub](https://github.com/wycats/handlebars.js/archives/master) and add it to your web pages (you should usually use the most recent version). +Installing Handlebars is easy. Simply download the package [from the +official site](http://handlebarsjs.com/) and add it to your web pages +(you should usually use the most recent version). Usage ----- -In general, the syntax of Handlebars.js templates is a superset of Mustache templates. For basic syntax, check out the [Mustache manpage](http://mustache.github.com/mustache.5.html). +In general, the syntax of Handlebars.js templates is a superset +of Mustache templates. For basic syntax, check out the [Mustache +manpage](http://mustache.github.com/mustache.5.html). -Once you have a template, use the Handlebars.compile method to compile the template into a function. The generated function takes a context argument, which will be used to render the template. +Once you have a template, use the Handlebars.compile method to compile +the template into a function. The generated function takes a context +argument, which will be used to render the template. ```js var source = "
Hello, my name is {{name}}. I am from {{hometown}}. I have " + @@ -75,25 +85,34 @@ To explicitly *not* escape the contents, use the triple-mustache Differences Between Handlebars.js and Mustache ---------------------------------------------- -Handlebars.js adds a couple of additional features to make writing templates easier and also changes a tiny detail of how partials work. +Handlebars.js adds a couple of additional features to make writing +templates easier and also changes a tiny detail of how partials work. ### Paths -Handlebars.js supports an extended expression syntax that we call paths. Paths are made up of typical expressions and . characters. Expressions allow you to not only display data from the current context, but to display data from contexts that are descendents and ancestors of the current context. +Handlebars.js supports an extended expression syntax that we call paths. +Paths are made up of typical expressions and . characters. Expressions +allow you to not only display data from the current context, but to +display data from contexts that are descendents and ancestors of the +current context. -To display data from descendent contexts, use the `.` character. So, for example, if your data were structured like: +To display data from descendent contexts, use the `.` character. So, for +example, if your data were structured like: ```js var data = {"person": { "name": "Alan" }, company: {"name": "Rad, Inc." } }; ``` -you could display the person's name from the top-level context with the following expression: +you could display the person's name from the top-level context with the +following expression: ``` {{person.name}} ``` -You can backtrack using `../`. For example, if you've already traversed into the person object you could still display the company's name with an expression like `{{../company.name}}`, so: +You can backtrack using `../`. For example, if you've already traversed +into the person object you could still display the company's name with +an expression like `{{../company.name}}`, so: ``` {{#person}}{{name}} - {{../company.name}}{{/person}} @@ -134,7 +153,9 @@ gets passed to the helper function. ### Block Helpers -Handlebars.js also adds the ability to define block helpers. Block helpers are functions that can be called from anywhere in the template. Here's an example: +Handlebars.js also adds the ability to define block helpers. Block +helpers are functions that can be called from anywhere in the template. +Here's an example: ```js var source = "
\nThis package implements a general-purpose JavaScript\nparser/compressor/beautifier toolkit. It is developed on NodeJS, but it\nshould work on any JavaScript platform supporting the CommonJS module system\n(and if your platform of choice doesn't support CommonJS, you can easily\nimplement it, or discard the exports.* lines from UglifyJS sources).\n
\nThe tokenizer/parser generates an abstract syntax tree from JS code. You\ncan then traverse the AST to learn more about the code, or do various\nmanipulations on it. This part is implemented in parse-js.js and it's a\nport to JavaScript of the excellent parse-js Common Lisp library from Marijn Haverbeke.\n
\n\n( See cl-uglify-js if you're looking for the Common Lisp version of\nUglifyJS. )\n
\n\nThe second part of this package, implemented in process.js, inspects and\nmanipulates the AST generated by the parser to provide the following:\n
\neval() calls or with{} statements. In short, if eval() or\n with{} are used in some scope, then all variables in that scope and any\n variables in the parent scopes will remain unmangled, and any references\n to such variables remain unmangled as well.\n\n{}\n\nreturn, throw, break or continue statement, except\n function/variable declarations).\n\n\nThe following transformations can in theory break code, although they're\nprobably safe in most practical cases. To enable them you need to pass the\n--unsafe flag.\n
\nThe following transformations occur:\n
\n\n\n\nnew Array(1, 2, 3, 4) => [1,2,3,4]\nArray(a, b, c) => [a,b,c]\nnew Array(5) => Array(5)\nnew Array(a) => Array(a)\n\n\n\n
\nThese are all safe if the Array name isn't redefined. JavaScript does allow\none to globally redefine Array (and pretty much everything, in fact) but I\npersonally don't see why would anyone do that.\n
\n\nUglifyJS does handle the case where Array is redefined locally, or even\nglobally but with a function or var declaration. Therefore, in the\nfollowing cases UglifyJS doesn't touch calls or instantiations of Array:\n
// case 1. globally declared variable\n var Array;\n new Array(1, 2, 3);\n Array(a, b);\n\n // or (can be declared later)\n new Array(1, 2, 3);\n var Array;\n\n // or (can be a function)\n new Array(1, 2, 3);\n function Array() { ... }\n\n// case 2. declared in a function\n (function(){\n a = new Array(1, 2, 3);\n b = Array(5, 6);\n var Array;\n })();\n\n // or\n (function(Array){\n return Array(5, 6, 7);\n })();\n\n // or\n (function(){\n return new Array(1, 2, 3, 4);\n function Array() { ... }\n })();\n\n // etc.\n\n\n\n
obj.toString() ==> obj+“” \nUglifyJS is now available through NPM — npm install uglify-js should do\nthe job.\n
## clone the repository\nmkdir -p /where/you/wanna/put/it\ncd /where/you/wanna/put/it\ngit clone git://github.com/mishoo/UglifyJS.git\n\n## make the module available to Node\nmkdir -p ~/.node_libraries/\ncd ~/.node_libraries/\nln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js\n\n## and if you want the CLI script too:\nmkdir -p ~/bin\ncd ~/bin\nln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs\n # (then add ~/bin to your $PATH if it's not there already)\n\n\n\n
\nThere is a command-line tool that exposes the functionality of this library\nfor your shell-scripting needs:\n
\n\n\n\nuglifyjs [ options... ] [ filename ]\n\n\n\n
\nfilename should be the last argument and should name the file from which\nto read the JavaScript code. If you don't specify it, it will read code\nfrom STDIN.\n
\nSupported options:\n
\n-b or --beautify — output indented code; when passed, additional\n options control the beautifier:\n\n-i N or --indent N — indentation level (number of spaces)\n\n-q or --quote-keys — quote keys in literal objects (by default,\n only keys that cannot be identifier names will be quotes).\n\n--ascii — pass this argument to encode non-ASCII characters as\n \\uXXXX sequences. By default UglifyJS won't bother to do it and will\n output Unicode characters instead. (the output is always encoded in UTF8,\n but if you pass this option you'll only get ASCII).\n\n-nm or --no-mangle — don't mangle names.\n\n-nmf or --no-mangle-functions – in case you want to mangle variable\n names, but not touch function names.\n\n-ns or --no-squeeze — don't call ast_squeeze() (which does various\n optimizations that result in smaller, less readable code).\n\n-mt or --mangle-toplevel — mangle names in the toplevel scope too\n (by default we don't do this).\n\n--no-seqs — when ast_squeeze() is called (thus, unless you pass\n --no-squeeze) it will reduce consecutive statements in blocks into a\n sequence. For example, \"a = 10; b = 20; foo();\" will be written as\n \"a=10,b=20,foo();\". In various occasions, this allows us to discard the\n block brackets (since the block becomes a single statement). This is ON\n by default because it seems safe and saves a few hundred bytes on some\n libs that I tested it on, but pass --no-seqs to disable it.\n\n--no-dead-code — by default, UglifyJS will remove code that is\n obviously unreachable (code that follows a return, throw, break or\n continue statement and is not a function/variable declaration). Pass\n this option to disable this optimization.\n\n-nc or --no-copyright — by default, uglifyjs will keep the initial\n comment tokens in the generated code (assumed to be copyright information\n etc.). If you pass this it will discard it.\n\n-o filename or --output filename — put the result in filename. If\n this isn't given, the result goes to standard output (or see next one).\n\n--overwrite — if the code is read from a file (not from STDIN) and you\n pass --overwrite then the output will be written in the same file.\n\n--ast — pass this if you want to get the Abstract Syntax Tree instead\n of JavaScript as output. Useful for debugging or learning more about the\n internals.\n\n-v or --verbose — output some notes on STDERR (for now just how long\n each operation takes).\n\n-d SYMBOL[=VALUE] or --define SYMBOL[=VALUE] — will replace\n all instances of the specified symbol where used as an identifier\n (except where symbol has properly declared by a var declaration or\n use as function parameter or similar) with the specified value. This\n argument may be specified multiple times to define multiple\n symbols - if no value is specified the symbol will be replaced with\n the value true, or you can specify a numeric value (such as\n 1024), a quoted string value (such as =\"object\"= or\n ='https://github.com'), or the name of another symbol or keyword (such as =null or document).\n This allows you, for example, to assign meaningful names to key\n constant values but discard the symbolic names in the uglified\n version for brevity/efficiency, or when used wth care, allows\n UglifyJS to operate as a form of conditional compilation\n whereby defining appropriate values may, by dint of the constant\n folding and dead code removal features above, remove entire\n superfluous code blocks (e.g. completely remove instrumentation or\n trace code for production use).\n Where string values are being defined, the handling of quotes are\n likely to be subject to the specifics of your command shell\n environment, so you may need to experiment with quoting styles\n depending on your platform, or you may find the option\n --define-from-module more suitable for use.\n\n-define-from-module SOMEMODULE — will load the named module (as\n per the NodeJS require() function) and iterate all the exported\n properties of the module defining them as symbol names to be defined\n (as if by the --define option) per the name of each property\n (i.e. without the module name prefix) and given the value of the\n property. This is a much easier way to handle and document groups of\n symbols to be defined rather than a large number of --define\n options.\n\n--unsafe — enable other additional optimizations that are known to be\n unsafe in some contrived situations, but could still be generally useful.\n For now only these:\n\n--max-line-len (default 32K characters) — add a newline after around\n 32K characters. I've seen both FF and Chrome croak when all the code was\n on a single line of around 670K. Pass –max-line-len 0 to disable this\n safety feature.\n\n--reserved-names — some libraries rely on certain names to be used, as\n pointed out in issue #92 and #81, so this option allow you to exclude such\n names from the mangler. For example, to keep names require and $super\n intact you'd specify –reserved-names \"require,$super\".\n\n--inline-script – when you want to include the output literally in an\n HTML <script> tag you can use this option to prevent </script from\n showing up in the output.\n\n--lift-vars – when you pass this, UglifyJS will apply the following\n transformations (see the notes in API, ast_lift_variables):\n\nvar declarations at the start of the scope\nvar declaration, if\n possible.\n\nTo use the library from JavaScript, you'd do the following (example for\nNodeJS):\n
\n\n\n\nvar jsp = require(\"uglify-js\").parser;\nvar pro = require(\"uglify-js\").uglify;\n\nvar orig_code = \"... JS code here\";\nvar ast = jsp.parse(orig_code); // parse code and get the initial AST\nast = pro.ast_mangle(ast); // get a new AST with mangled names\nast = pro.ast_squeeze(ast); // get an AST with compression optimizations\nvar final_code = pro.gen_code(ast); // compressed code here\n\n\n\n
\nThe above performs the full compression that is possible right now. As you\ncan see, there are a sequence of steps which you can apply. For example if\nyou want compressed output but for some reason you don't want to mangle\nvariable names, you would simply skip the line that calls\npro.ast_mangle(ast).\n
\nSome of these functions take optional arguments. Here's a description:\n
\njsp.parse(code, strict_semicolons) – parses JS code and returns an AST.\n strict_semicolons is optional and defaults to false. If you pass\n true then the parser will throw an error when it expects a semicolon and\n it doesn't find it. For most JS code you don't want that, but it's useful\n if you want to strictly sanitize your code.\n\npro.ast_lift_variables(ast) – merge and move var declarations to the\n scop of the scope; discard unused function arguments or variables; discard\n unused (named) inner functions. It also tries to merge assignments\n following the var declaration into it.\n\n\n If your code is very hand-optimized concerning var declarations, this\n lifting variable declarations might actually increase size. For me it\n helps out. On jQuery it adds 865 bytes (243 after gzip). YMMV. Also\n note that (since it's not enabled by default) this operation isn't yet\n heavily tested (please report if you find issues!).\n
\n Note that although it might increase the image size (on jQuery it gains\n 865 bytes, 243 after gzip) it's technically more correct: in certain\n situations, dead code removal might drop variable declarations, which\n would not happen if the variables are lifted in advance.\n
\n\n Here's an example of what it does:\n
function f(a, b, c, d, e) {\n var q;\n var w;\n w = 10;\n q = 20;\n for (var i = 1; i < 10; ++i) {\n var boo = foo(a);\n }\n for (var i = 0; i < 1; ++i) {\n var boo = bar(c);\n }\n function foo(){ ... }\n function bar(){ ... }\n function baz(){ ... }\n}\n\n// transforms into ==>\n\nfunction f(a, b, c) {\n var i, boo, w = 10, q = 20;\n for (i = 1; i < 10; ++i) {\n boo = foo(a);\n }\n for (i = 0; i < 1; ++i) {\n boo = bar(c);\n }\n function foo() { ... }\n function bar() { ... }\n}\n\n\n\n
pro.ast_mangle(ast, options) – generates a new AST containing mangled\n (compressed) variable and function names. It supports the following\n options:\n\ntoplevel – mangle toplevel names (by default we don't touch them).\nexcept – an array of names to exclude from compression.\ndefines – an object with properties named after symbols to\n replace (see the --define option for the script) and the values\n representing the AST replacement value.\n\npro.ast_squeeze(ast, options) – employs further optimizations designed\n to reduce the size of the code that gen_code would generate from the\n AST. Returns a new AST. options can be a hash; the supported options\n are:\n\nmake_seqs (default true) which will cause consecutive statements in a\n block to be merged using the \"sequence\" (comma) operator\n\ndead_code (default true) which will remove unreachable code.\n\npro.gen_code(ast, options) – generates JS code from the AST. By\n default it's minified, but using the options argument you can get nicely\n formatted output. options is, well, optional :-) and if you pass it it\n must be an object and supports the following properties (below you can see\n the default values):\n\nbeautify: false – pass true if you want indented output\nindent_start: 0 (only applies when beautify is true) – initial\n indentation in spaces\nindent_level: 4 (only applies when beautify is true) --\n indentation level, in spaces (pass an even number)\nquote_keys: false – if you pass true it will quote all keys in\n literal objects\nspace_colon: false (only applies when beautify is true) – wether\n to put a space before the colon in object literals\nascii_only: false – pass true if you want to encode non-ASCII\n characters as \\uXXXX.\ninline_script: false – pass true to escape occurrences of\n </script in strings\n\nThe beautifier can be used as a general purpose indentation tool. It's\nuseful when you want to make a minified file readable. One limitation,\nthough, is that it discards all comments, so you don't really want to use it\nto reformat your code, unless you don't have, or don't care about, comments.\n
\n\nIn fact it's not the beautifier who discards comments — they are dumped at\nthe parsing stage, when we build the initial AST. Comments don't really\nmake sense in the AST, and while we could add nodes for them, it would be\ninconvenient because we'd have to add special rules to ignore them at all\nthe processing stages.\n
\n\nThe --define option can be used, particularly when combined with the\nconstant folding logic, as a form of pre-processor to enable or remove\nparticular constructions, such as might be used for instrumenting\ndevelopment code, or to produce variations aimed at a specific\nplatform.\n
\nThe code below illustrates the way this can be done, and how the\nsymbol replacement is performed.\n
\n\n\n\nCLAUSE1: if (typeof DEVMODE === 'undefined') {\n DEVMODE = true;\n}\n\nCLAUSE2: function init() {\n if (DEVMODE) {\n console.log(\"init() called\");\n }\n ....\n DEVMODE && console.log(\"init() complete\");\n}\n\nCLAUSE3: function reportDeviceStatus(device) {\n var DEVMODE = device.mode, DEVNAME = device.name;\n if (DEVMODE === 'open') {\n ....\n }\n}\n\n\n\n
\nWhen the above code is normally executed, the undeclared global\nvariable DEVMODE will be assigned the value true (see CLAUSE1)\nand so the init() function (CLAUSE2) will write messages to the\nconsole log when executed, but in CLAUSE3 a locally declared\nvariable will mask access to the DEVMODE global symbol.\n
\nIf the above code is processed by UglifyJS with an argument of\n--define DEVMODE=false then UglifyJS will replace DEVMODE with the\nboolean constant value false within CLAUSE1 and CLAUSE2, but it\nwill leave CLAUSE3 as it stands because there DEVMODE resolves to\na validly declared variable.\n
\nAnd more so, the constant-folding features of UglifyJS will recognise\nthat the if condition of CLAUSE1 is thus always false, and so will\nremove the test and body of CLAUSE1 altogether (including the\notherwise slightly problematical statement false = true; which it\nwill have formed by replacing DEVMODE in the body). Similarly,\nwithin CLAUSE2 both calls to console.log() will be removed\naltogether.\n
\nIn this way you can mimic, to a limited degree, the functionality of\nthe C/C++ pre-processor to enable or completely remove blocks\ndepending on how certain symbols are defined - perhaps using UglifyJS\nto generate different versions of source aimed at different\nenvironments\n
\n\nIt is recommmended (but not made mandatory) that symbols designed for\nthis purpose are given names consisting of UPPER_CASE_LETTERS to\ndistinguish them from other (normal) symbols and avoid the sort of\nclash that CLAUSE3 above illustrates.\n
\nHere are updated statistics. (I also updated my Google Closure and YUI\ninstallations).\n
\n\nWe're still a lot better than YUI in terms of compression, though slightly\nslower. We're still a lot faster than Closure, and compression after gzip\nis comparable.\n
\n| File | UglifyJS | UglifyJS+gzip | Closure | Closure+gzip | YUI | YUI+gzip |
|---|---|---|---|---|---|---|
| jquery-1.6.2.js | 91001 (0:01.59) | 31896 | 90678 (0:07.40) | 31979 | 101527 (0:01.82) | 34646 |
| paper.js | 142023 (0:01.65) | 43334 | 134301 (0:07.42) | 42495 | 173383 (0:01.58) | 48785 |
| prototype.js | 88544 (0:01.09) | 26680 | 86955 (0:06.97) | 26326 | 92130 (0:00.79) | 28624 |
| thelib-full.js (DynarchLIB) | 251939 (0:02.55) | 72535 | 249911 (0:09.05) | 72696 | 258869 (0:01.94) | 76584 |
\nUnfortunately, for the time being there is no automated test suite. But I\nran the compressor manually on non-trivial code, and then I tested that the\ngenerated code works as expected. A few hundred times.\n
\n\nDynarchLIB was started in times when there was no good JS minifier.\nTherefore I was quite religious about trying to write short code manually,\nand as such DL contains a lot of syntactic hacks1 such as “foo == bar ? a\n= 10 : b = 20”, though the more readable version would clearly be to use\n“if/else”.\n
\n\nSince the parser/compressor runs fine on DL and jQuery, I'm quite confident\nthat it's solid enough for production use. If you can identify any bugs,\nI'd love to hear about them (use the Google Group or email me directly).\n
\n\nUglifyJS is released under the BSD license:\n
\n\n\n\nCopyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com>\nBased on parse-js (http://marijn.haverbeke.nl/parse-js/).\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n * Redistributions of source code must retain the above\n copyright notice, this list of conditions and the following\n disclaimer.\n\n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials\n provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY\nEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\nOR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR\nTORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF\nTHE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGE.\n\n\n\n\n
Hello, my name is {{name}}. I am from {{hometown}}. I have \" +\n \"{{kids.length}} kids:
\" +\n \"Hello, my name is Alan. I am from Somewhere, TX. I have 2 kids:
\n//\nPrecompile handlebar templates.\nUsage: handlebars template...\n\nOptions:\n -a, --amd Create an AMD format function (allows loading with RequireJS) [boolean]\n -f, --output Output File [string]\n -k, --known Known helpers [string]\n -o, --knownOnly Known helpers only [boolean]\n -m, --min Minimize output [boolean]\n -s, --simple Output template function only. [boolean]\n -r, --root Template root. Base value that will be stripped from template names. [string]\n\n\nIf using the precompiler's normal mode, the resulting templates will be\nstored to the `Handlebars.templates` object using the relative template\nname sans the extension. These templates may be executed in the same\nmanner as templates.\n\nIf using the simple mode the precompiler will generate a single\njavascript method. To execute this method it must be passed to the using\nthe `Handlebars.template` method and the resulting object may be as\nnormal.\n\n### Optimizations\n\n- Rather than using the full _handlebars.js_ library, implementations that\n do not need to compile templates at runtime may include _handlebars.runtime.js_\n whose min+gzip size is approximately 1k.\n- If a helper is known to exist in the target environment they may be defined\n using the `--known name` argument may be used to optimize accesses to these\n helpers for size and speed.\n- When all helpers are known in advance the `--knownOnly` argument may be used\n to optimize all block helper references.\n\n\nPerformance\n-----------\n\nIn a rough performance test, precompiled Handlebars.js templates (in\nthe original version of Handlebars.js) rendered in about half the\ntime of Mustache templates. It would be a shame if it were any other\nway, since they were precompiled, but the difference in architecture\ndoes have some big performance advantages. Justin Marney, a.k.a.\n[gotascii](http://github.com/gotascii), confirmed that with an\n[independent test](http://sorescode.com/2010/09/12/benchmarks.html). The\nrewritten Handlebars (current version) is faster than the old version,\nand we will have some benchmarks in the near future.\n\n\nBuilding\n--------\n\nTo build handlebars, just run `rake release`, and you will get two files\nin the `dist` directory.\n\n\nUpgrading\n---------\n\nWhen upgrading from the Handlebars 0.9 series, be aware that the\nsignature for passing custom helpers or partials to templates has\nchanged.\n\nInstead of:\n\n```js\ntemplate(context, helpers, partials, [data])\n```\n\nUse:\n\n```js\ntemplate(context, {helpers: helpers, partials: partials, data: data})\n```\n\nKnown Issues\n------------\n* Handlebars.js can be cryptic when there's an error while rendering.\n* Using a variable, helper, or partial named `class` causes errors in IE browsers. (Instead, use `className`)\n\nHandlebars in the Wild\n-----------------\n* [jblotus](http://github.com/jblotus) created [http://tryhandlebarsjs.com](http://tryhandlebarsjs.com)\n for anyone who would like to try out Handlebars.js in their browser.\n* Don Park wrote an Express.js view engine adapter for Handlebars.js called\n [hbs](http://github.com/donpark/hbs).\n* [sammy.js](http://github.com/quirkey/sammy) by Aaron Quint, a.k.a. quirkey,\n supports Handlebars.js as one of its template plugins.\n* [SproutCore](http://www.sproutcore.com) uses Handlebars.js as its main\n templating engine, extending it with automatic data binding support.\n* [Ember.js](http://www.emberjs.com) makes Handlebars.js the primary way to\n structure your views, also with automatic data binding support.\n* Les Hill (@leshill) wrote a Rails Asset Pipeline gem named\n handlebars_assets](http://github.com/leshill/handlebars_assets).\n* [Gist about Synchronous and asynchronous loading of external handlebars templates](https://gist.github.com/2287070)\n\nHelping Out\n-----------\nTo build Handlebars.js you'll need a few things installed.\n\n* Node.js\n* Jison, for building the compiler - `npm install jison`\n* Ruby\n* therubyracer, for running tests - `gem install therubyracer`\n* rspec, for running tests - `gem install rspec`\n\nThere's a Gemfile in the repo, so you can run `bundle` to install rspec\nand therubyracer if you've got bundler installed.\n\nTo build Handlebars.js from scratch, you'll want to run `rake compile`\nin the root of the project. That will build Handlebars and output the\nresults to the dist/ folder. To run tests, run `rake spec`. You can also\nrun our set of benchmarks with `rake bench`.\n\nIf you notice any problems, please report\nthem to the GitHub issue tracker at\n[http://github.com/wycats/handlebars.js/issues](http://github.com/wycats/handlebars.js/issues).\nFeel free to contact commondream or wycats through GitHub with any other\nquestions or feature requests. To submit changes fork the project and\nsend a pull request.\n\nLicense\n-------\nHandlebars.js is released under the MIT license.\n\n", + "readmeFilename": "README.markdown", + "bugs": { + "url": "https://github.com/wycats/handlebars.js/issues" + }, + "_id": "handlebars@1.0.11", + "dist": { + "shasum": "0a7f8ac34a41929ce1a9b0429283b31c76812b17" + }, + "_from": "handlebars@1.0.11", + "_resolved": "https://registry.npmjs.org/handlebars/-/handlebars-1.0.11.tgz" } diff --git a/node_modules/handlebars/release-notes.md b/node_modules/handlebars/release-notes.md new file mode 100644 index 0000000000..fb409c6866 --- /dev/null +++ b/node_modules/handlebars/release-notes.md @@ -0,0 +1,55 @@ +# Release Notes + +## Development + +[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.11...master) + +## v1.0.11 / 1.0.0-rc4 - May 13 2013 + +- [#458](https://github.com/wycats/handlebars.js/issues/458) - Fix `./foo` syntax ([@jpfiset](https://github.com/jpfiset)) +- [#460](https://github.com/wycats/handlebars.js/issues/460) - Allow `:` in unescaped identifers ([@jpfiset](https://github.com/jpfiset)) +- [#471](https://github.com/wycats/handlebars.js/issues/471) - Create release notes (These!) +- [#456](https://github.com/wycats/handlebars.js/issues/456) - Allow escaping of `\\` +- [#211](https://github.com/wycats/handlebars.js/issues/211) - Fix exception in `escapeExpression` +- [#375](https://github.com/wycats/handlebars.js/issues/375) - Escape unicode newlines +- [#461](https://github.com/wycats/handlebars.js/issues/461) - Do not fail when compiling `""` +- [#302](https://github.com/wycats/handlebars.js/issues/302) - Fix sanity check in knownHelpersOnly mode +- [#369](https://github.com/wycats/handlebars.js/issues/369) - Allow registration of multiple helpers and partial by passing definition object +- Add bower package declaration ([@DevinClark](https://github.com/DevinClark)) +- Add NuSpec package declaration ([@MikeMayer](https://github.com/MikeMayer)) +- Handle empty context in `with` ([@thejohnfreeman](https://github.com/thejohnfreeman)) +- Support custom template extensions in CLI ([@matteoagosti](https://github.com/matteoagosti)) +- Fix Rhino support ([@broady](https://github.com/broady)) +- Include contexts in string mode ([@leshill](https://github.com/leshill)) +- Return precompiled scripts when compiling to AMD ([@JamesMaroney](https://github.com/JamesMaroney)) +- Docs updates ([@iangreenleaf](https://github.com/iangreenleaf), [@gilesbowkett](https://github.com/gilesbowkett), [@utkarsh2012](https://github.com/utkarsh2012)) +- Fix `toString` handling under IE and browserify ([@tommydudebreaux](https://github.com/tommydudebreaux)) +- Add program metadata + +[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.10...master) + +## v1.0.10 - Node - Feb 27 2013 + +- [#428](https://github.com/wycats/handlebars.js/issues/428) - Fix incorrect rendering of nested programs +- Fix exception message ([@tricknotes](https://github.com/tricknotes)) +- Added negative number literal support +- Concert library to single IIFE +- Add handlebars-source gemspec ([@machty](https://github.com/machty)) + +[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.9...v1.0.10) + +## v1.0.9 - Node - Feb 15 2013 + +- Added `Handlebars.create` API in node module for sandboxed instances ([@tommydudebreaux](https://github.com/tommydudebreaux)) + +[Commits](https://github.com/wycats/handlebars.js/compare/1.0.0-rc.3...v1.0.9) + +## 1.0.0-rc3 - Browser - Feb 14 2013 + +- Prevent use of `this` or `..` in illogical place ([@leshill](https://github.com/leshill)) +- Allow AST passing for `parse`/`compile`/`precompile` ([@machty](https://github.com/machty)) +- Optimize generated output by inlining statements where possible +- Check compiler version when evaluating templates +- Package browser dist in npm package + +[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.8...1.0.0-rc.3) diff --git a/node_modules/handlebars/test.js b/node_modules/handlebars/test.js new file mode 100644 index 0000000000..0a6dde50d5 --- /dev/null +++ b/node_modules/handlebars/test.js @@ -0,0 +1,20 @@ +var Handlebars = require('./lib/handlebars'); + +var succeedingTemplate = '{{#inverse}} {{#blk}} Unexpected {{/blk}} {{else}} {{#blk}} Expected {{/blk}} {{/inverse}}'; +var failingTemplate = '{{#inverse}} {{#blk}} Unexpected {{/blk}} {{else}} {{#blk}} Expected {{/blk}} {{/inverse}}'; + +console.log(Handlebars.precompile(failingTemplate)); + +var helpers = { + blk: function(block) { return block.fn(''); }, + inverse: function(block) { return block.inverse(''); } +}; + +function output(template_string) { + var compiled = Handlebars.compile(template_string); + var out = compiled({}, {helpers: helpers}); + console.log(out); +} + + +output(failingTemplate); // output: Unexpected diff --git a/static/third/handlebars/handlebars.runtime.js b/static/third/handlebars/handlebars.runtime.js index 66b3d4608c..48307f3682 100644 --- a/static/third/handlebars/handlebars.runtime.js +++ b/static/third/handlebars/handlebars.runtime.js @@ -46,31 +46,45 @@ THE SOFTWARE. */ +// lib/handlebars/browser-prefix.js +var Handlebars = {}; + +(function(Handlebars, undefined) { +; // lib/handlebars/base.js -/*jshint eqnull:true*/ -this.Handlebars = {}; - -(function(Handlebars) { - -Handlebars.VERSION = "1.0.0-rc.3"; -Handlebars.COMPILER_REVISION = 2; +Handlebars.VERSION = "1.0.0-rc.4"; +Handlebars.COMPILER_REVISION = 3; Handlebars.REVISION_CHANGES = { 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it - 2: '>= 1.0.0-rc.3' + 2: '== 1.0.0-rc.3', + 3: '>= 1.0.0-rc.4' }; Handlebars.helpers = {}; Handlebars.partials = {}; +var toString = Object.prototype.toString, + functionType = '[object Function]', + objectType = '[object Object]'; + Handlebars.registerHelper = function(name, fn, inverse) { - if(inverse) { fn.not = inverse; } - this.helpers[name] = fn; + if (toString.call(name) === objectType) { + if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); } + Handlebars.Utils.extend(this.helpers, name); + } else { + if (inverse) { fn.not = inverse; } + this.helpers[name] = fn; + } }; Handlebars.registerPartial = function(name, str) { - this.partials[name] = str; + if (toString.call(name) === objectType) { + Handlebars.Utils.extend(this.partials, name); + } else { + this.partials[name] = str; + } }; Handlebars.registerHelper('helperMissing', function(arg) { @@ -81,13 +95,9 @@ Handlebars.registerHelper('helperMissing', function(arg) { } }); -var toString = Object.prototype.toString, functionType = "[object Function]"; - Handlebars.registerHelper('blockHelperMissing', function(context, options) { var inverse = options.inverse || function() {}, fn = options.fn; - - var ret = ""; var type = toString.call(context); if(type === functionType) { context = context.call(this); } @@ -178,23 +188,17 @@ Handlebars.registerHelper('if', function(context, options) { }); Handlebars.registerHelper('unless', function(context, options) { - var fn = options.fn, inverse = options.inverse; - options.fn = inverse; - options.inverse = fn; - - return Handlebars.helpers['if'].call(this, context, options); + return Handlebars.helpers['if'].call(this, context, {fn: options.inverse, inverse: options.fn}); }); Handlebars.registerHelper('with', function(context, options) { - return options.fn(context); + if (!Handlebars.Utils.isEmpty(context)) return options.fn(context); }); Handlebars.registerHelper('log', function(context, options) { var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1; Handlebars.log(level, context); }); - -}(this.Handlebars)); ; // lib/handlebars/utils.js @@ -218,48 +222,61 @@ Handlebars.SafeString.prototype.toString = function() { return this.string.toString(); }; -(function() { - var escape = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'", - "`": "`" - }; +var escape = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" +}; - var badChars = /[&<>"'`]/g; - var possible = /[&<>"'`]/; +var badChars = /[&<>"'`]/g; +var possible = /[&<>"'`]/; - var escapeChar = function(chr) { - return escape[chr] || "&"; - }; +var escapeChar = function(chr) { + return escape[chr] || "&"; +}; - Handlebars.Utils = { - escapeExpression: function(string) { - // don't escape SafeStrings, since they're already safe - if (string instanceof Handlebars.SafeString) { - return string.toString(); - } else if (string == null || string === false) { - return ""; - } - - if(!possible.test(string)) { return string; } - return string.replace(badChars, escapeChar); - }, - - isEmpty: function(value) { - if (!value && value !== 0) { - return true; - } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) { - return true; - } else { - return false; +Handlebars.Utils = { + extend: function(obj, value) { + for(var key in value) { + if(value.hasOwnProperty(key)) { + obj[key] = value[key]; } } - }; -})();; + }, + + escapeExpression: function(string) { + // don't escape SafeStrings, since they're already safe + if (string instanceof Handlebars.SafeString) { + return string.toString(); + } else if (string == null || string === false) { + return ""; + } + + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = string.toString(); + + if(!possible.test(string)) { return string; } + return string.replace(badChars, escapeChar); + }, + + isEmpty: function(value) { + if (!value && value !== 0) { + return true; + } else if(toString.call(value) === "[object Array]" && value.length === 0) { + return true; + } else { + return false; + } + } +}; +; // lib/handlebars/runtime.js + Handlebars.VM = { template: function(templateSpec) { // Just add water @@ -270,13 +287,11 @@ Handlebars.VM = { program: function(i, fn, data) { var programWrapper = this.programs[i]; if(data) { - return Handlebars.VM.program(fn, data); - } else if(programWrapper) { - return programWrapper; - } else { - programWrapper = this.programs[i] = Handlebars.VM.program(fn); - return programWrapper; + programWrapper = Handlebars.VM.program(i, fn, data); + } else if (!programWrapper) { + programWrapper = this.programs[i] = Handlebars.VM.program(i, fn); } + return programWrapper; }, programWithDepth: Handlebars.VM.programWithDepth, noop: Handlebars.VM.noop, @@ -308,21 +323,27 @@ Handlebars.VM = { }; }, - programWithDepth: function(fn, data, $depth) { - var args = Array.prototype.slice.call(arguments, 2); + programWithDepth: function(i, fn, data /*, $depth */) { + var args = Array.prototype.slice.call(arguments, 3); - return function(context, options) { + var program = function(context, options) { options = options || {}; return fn.apply(this, [context, options.data || data].concat(args)); }; + program.program = i; + program.depth = args.length; + return program; }, - program: function(fn, data) { - return function(context, options) { + program: function(i, fn, data) { + var program = function(context, options) { options = options || {}; return fn(context, options.data || data); }; + program.program = i; + program.depth = 0; + return program; }, noop: function() { return ""; }, invokePartial: function(partial, name, context, helpers, partials, data) { @@ -343,3 +364,6 @@ Handlebars.VM = { Handlebars.template = Handlebars.VM.template; ; +// lib/handlebars/browser-suffix.js +})(Handlebars); +;