summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/javascript-compiler.js
Commit message (Collapse)AuthorAgeFilesLines
* Use objects for hash value trackingkpdecker2016-03-111-1/+1
| | | | | | The use of arrays was incorrect for the data type and causing problems when hash keys conflicted with array behaviors. Fixes #1194
* Ensure that existing blockParams and depths are respected on dupe programsCharles O'Farrell2016-03-081-8/+10
| | | | Fixes #1186
* Remove stringParams and trackIds modemachty2015-12-101-105/+1
| | | | Closes #1145
* Fix lint errors under latest eslintkpdecker2015-10-311-1/+1
|
* Fix iteration over undefined valueskpdecker2015-09-231-2/+3
| | | | | Allow for iteration on undefined values, but special case undefined and null to prevent rendering errors when not running in strict mode. Fixes #1093
* Fix failure when using decorators in partialskpdecker2015-09-021-0/+1
|
* Update to latest eslintkpdecker2015-09-011-2/+2
|
* Implement block decoratorskpdecker2015-08-221-4/+67
| | | | These allow for a given block to be wrapped in helper methods or metadata and allow for more control over the current container and method before the code is run.
* Pass container rather than exec as contextkpdecker2015-08-181-10/+10
| | | There is no real need for us to do `.call(container` other than for backwards compatibility with legacy versions. Using the 4.x release as a chance to optimize this behavior.
* Remove unused parameterskpdecker2015-08-181-2/+2
|
* Pass undefined fields to helpers in strict modekpdecker2015-08-031-6/+6
| | | | | This allows for `{{helper foo}}` to still operate under strict mode when `foo` is not defined on the context. This allows helpers to perform whatever existence checks they please so patterns like `{{#if foo}}{{foo}}{{/if}}` can be used to protect against missing values. Fixes #1063
* Fix escaping of non-javascript identifierskpdecker2015-08-011-1/+1
| | | | The ‘ character would cause invalid javascript to be generated as it was not properly escaped. Switching to JSON.stringify safely handles all potential unescaped cases.
* Remove jshint completelykpdecker2015-04-271-2/+0
|
* Update for let and optional parameterskpdecker2015-04-201-69/+66
|
* Add full support for es6kpdecker2015-04-161-42/+46
| | | | | | | | Converts the tool chain to use babel, eslint, and webpack vs. the previous proprietary solutions. Additionally begins enforcing additional linting concerns as well as updates the code to reflect these rules. Fixes #855 Fixes #993
* Add support for dynamic partial nameskpdecker2015-01-181-2/+11
| | | | | | | | | Uses the subexpression syntax to allow for dynamic partial lookups. Ex: ``` {{> (helper) }} ``` Fixes #933
* Add missing reserved words so compiler knows to use array syntax:Matthew Flaschen2015-01-171-1/+2
| | | | | | | | | | | | | | | | * await * null * true * false IE 8 was failing to compile Handlebars-generated source code because it had helpers.null. I came up with this list by diffing https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords against the ones Handlebars already had. I added two corresponding tests for nameLookup.
* Implement strict and assumeObject modeskpdecker2014-12-271-7/+42
| | | | | | | | Causes templates to throw when lookup fields are not defined within the context. Strict mode will throw when any field is omitted. assumeObjects mode maintains the existing behavior of outputting an empty response when fields are not defined but allows for performance/size optimizations by not doing safety checks for intermediate objects in the lookup chain. Strict mode effectively disables the helperMissing and inverse handling for blockHelperMissing as templates will throw rather than call those features for missing data fields. Fixes #651 Fixes #805
* Strip unnecessary whitespace in template outputkpdecker2014-12-271-1/+1
|
* Fix duplicate return statement on simple templateskpdecker2014-12-271-1/+1
|
* Implement block parameterskpdecker2014-12-261-25/+57
| | | Fixes #907
* Update fix for #926 for 3.0 codelinekpdecker2014-12-171-1/+1
|
* Track depths on deduped childrenkpdecker2014-12-161-0/+2
| | | | | Fixes a very specific error case where deduped children won’t receive the depths object due to it being omitted by the caller when optimizing. Fixes #926
* Remove unused vars and add jshint checkingkpdecker2014-12-161-1/+0
|
* Remove Compiler.depths parameterkpdecker2014-12-161-4/+2
| | | | This is no longer necessary with the depths array tracking and adds compiler overhead.
* Add basic docs for JavaScriptCompiler override APIkpdecker2014-11-291-9/+9
|
* Drop unused JavaScriptCompiler.namespace paramkpdecker2014-11-291-2/+0
|
* Treat partial exec in a manner closer to helperskpdecker2014-11-271-16/+25
| | | This helps unify the code handling and will also be needed to support string/id tracking on partials.
* Update subexpression and hash AST constructskpdecker2014-11-271-2/+2
|
* Replace DataNode and IdNode with PathNodekpdecker2014-11-261-1/+1
| | | This is a breaking change for string mode users as there is no longer a distinct type for data parameters. Instead data consumers should look for the @ prefix value.
* Update AST location info to match SpiderMonkeykpdecker2014-11-261-1/+1
| | | Part of #889
* Optimize variable declarationkpdecker2014-11-251-2/+1
|
* Propagate options for client compiled partialskpdecker2014-11-081-0/+2
| | | Fixes #901
* Only provide aliases for multiple use callskpdecker2014-11-081-26/+39
| | | Fixes #903
* Provide default mapping for boilerplate codekpdecker2014-11-081-1/+5
|
* Generate source mapskpdecker2014-11-081-100/+124
| | | | | | Allow the precompiler to generate source maps when the srcFile parameter is passed. This refactors large chunks of the code generation pipeline, allowing metadata to be associated with code chunks as well as breaking out much of the code generation logic into a separate helper.
* Include location information in all opcodeskpdecker2014-11-081-0/+1
|
* Simplify program generation logickpdecker2014-11-081-10/+2
|
* Bump test coveragekpdecker2014-11-081-2/+2
|
* Ignore unused code pathskpdecker2014-11-081-0/+2
| | | | We don’t want to remove these as the generic code may need it in the future, but these code paths are not triggered through the existing language constructs.
* Merge setupParams and setupOptionskpdecker2014-11-061-9/+2
|
* Simplify flushInline implementationkpdecker2014-11-051-19/+10
|
* Use terinary operator for inline appendskpdecker2014-11-051-7/+12
| | | | Allows for append operations to avoid breaking inline chain.
* Render false literal as “false”kpdecker2014-08-251-1/+1
| | | Fixes #827
* Prune unused codekpdecker2014-08-251-1/+1
|
* Restore helperMissing for ambiguous statementskpdecker2014-08-231-1/+2
| | | | Fixes #318 (regression) Partial fix for #783
* Cleanup from code coverage reportkpdecker2014-08-231-11/+7
|
* Move strip processing into AST helper logickpdecker2014-08-231-22/+0
| | | | | We already have to track these behaviors for the standalone parsing and rather than having two whitespace pruning implementations this moves all of the behavior into one place. Fixes #852
* Optimize replaceStack for inline methodskpdecker2014-08-231-40/+24
| | | Only use case was with inline input so most of this code was unnecessary.
* Remove unnecessary stack variable from blockHelperkpdecker2014-08-231-4/+4
|
* Do not flush subexpressionskpdecker2014-08-231-7/+0
| | | | | | They are no longer duplicated with the new helper calling pattern and this also introduced stack corruption issues due to improper value lookups. Fixes #767 Fixes #768
* Fix undefined handling for pathed lookupskpdecker2014-08-151-4/+3
| | | | Fixes #837
* Strip dead code from javascript compilerkpdecker2014-08-151-9/+2
|
* Fix compat partial exec without datakpdecker2014-08-151-0/+2
|
* Make depthed lookup call non-literalkpdecker2014-08-151-1/+1
| | | Prevents duplicate calls from being made.
* Drop unused DECLARE opcodekpdecker2014-08-141-5/+1
|
* Increase test coverage a touchkpdecker2014-08-141-4/+2
|
* Implement partial recursive lookupkpdecker2014-08-141-1/+4
|
* Inherit compat flag for partialskpdecker2014-08-141-1/+4
|
* Implement recursive field lookup in compat modekpdecker2014-08-131-7/+17
| | | | | | Provides the mustache behavior of recursive lookup without the use of depthed paths. Note that this does incur a fairly dramatic performance penalty for depthed queries.
* Use depths array rather than passing array argskpdecker2014-08-131-9/+20
| | | Approximately doubles the throughput performance of depthed templates and clears the way for doing recursive path lookups in pathed mode.
* Create contextName helper for context lookupkpdecker2014-08-131-7/+10
|
* Render indent for standalone partialskpdecker2014-08-121-2/+2
|
* Remove unused JSCompiler.register methodkpdecker2014-08-111-5/+0
|
* Do not lookup pathed helpers on the helper stackkpdecker2014-07-121-5/+4
| | | | Fixes #764
* Fix rendering of paths that resolve to zerokpdecker2014-07-121-1/+1
| | | | Fixes #820
* Use ID lookup for ambiguous helper evaluationkpdecker2014-07-071-1/+2
| | | Final change for #731
* Rework lookup null protector logickpdecker2014-07-061-54/+62
| | | | | | | - Move the lookup null protection out of `nameLookup` and into that contexts that are aware of the needs for falsy vs. not displayed values. - Optimize lookup for nested path operations Fixes #731
* Move lambda resolution to runtimekpdecker2014-07-061-4/+2
| | | This has a very positive impact on precompiled output size, particularly for known-helpers cases, and little or no impact on the throughput numbers.
* Remove disassemble log statementkpdecker2014-06-281-3/+1
| | | Fixes #772
* Fix evaluation of paths and subexprskpdecker2014-03-051-5/+8
| | | Fixes #743
* Merge pull request #749 from jenseng/option_subexpressions_fixKevin Decker2014-03-051-4/+3
|\ | | | | properly handle multiple subexpressions in the same hash, fixes #748
| * properly handle multiple subexpressions in the same hash, fixes #748Jon Jensen2014-02-201-4/+3
| | | | | | | | | | push all hash params before popping any so as to avoid the last stackN var stomping previous ones
* | fix bug in IE<=8 (no Array::map), closes #751Jon Jensen2014-03-041-9/+11
|/ | | | | | | looks like this broke in 2812fe27 also s/this.i/var i/, since the functions that needed it were removed in a1edab6ef
* Add support for depthed resolution of data fieldskpdecker2014-02-091-2/+6
|
* Optimize buffer generate first and all edge caseskpdecker2014-02-091-26/+39
|
* Merge pull request #729 from wycats/precompile-literalKevin Decker2014-02-081-57/+55
|\ | | | | Convert template spec to object literal
| * Convert template spec to object literalkpdecker2014-02-061-57/+55
| | | | | | This allows for metadata to be associated with the template and a simplification of the template init logic.
* | Remove unnecessary conditionalkpdecker2014-02-061-3/+1
|/
* Add trackIds compiler flagkpdecker2014-01-171-3/+36
| | | | Allows helpers that care about where a particular field came from derive this data while maintaining backward compatibility with existing helpers.
* Fix missing parameters for pathed mustacheskpdecker2014-01-171-1/+1
| | | Fixes #658
* Implement partial hash evaluationkpdecker2014-01-171-1/+1
|
* Improve usefulness of extend util, properly use namespace property, update ↵Blake Embrey2014-01-161-17/+28
| | | | setup options to use a hash helper.
* Merge pull request #634 from wycats/name-optionKevin Decker2014-01-151-18/+13
|\ | | | | It would be great to have the helper name passed to `blockHelperMissing`
| * Cleanup now unused code in jscompilerkpdecker2014-01-061-5/+4
| |
| * Include name option for all helper callskpdecker2014-01-061-15/+11
| | | | | | | | | | | | | | | | All helper calls will have access to `options.name` which is the first id value of the mustache operation. As part of this the helperMissing call has been simplified to remove the indexed name in order to optimize the call. This is a breaking change. Fixes #634
* | Expose the initial context via @rootkpdecker2014-01-151-1/+1
|/
* Track stringParams mode in local state varskpdecker2014-01-061-6/+7
|
* Remove redundant conditions.Blake Embrey2014-01-051-4/+1
|
* Simplify ambiguous codekpdecker2014-01-041-9/+9
| | | | Remove if conditional in favor of boolean failover.
* Merge branch 'compiler-options' of github.com:blakeembrey/handlebars.js into ↵kpdecker2014-01-011-4/+9
|\ | | | | | | | | | | | | blakeembrey-compiler-options Conflicts: lib/handlebars/compiler/javascript-compiler.js
| * Pull options out from param setup to allow easier extension.Blake Embrey2013-12-281-5/+10
| |
* | Remove duplication from generated subexpressionskpdecker2014-01-011-12/+38
| |
* | Whitespace cleanupkpdecker2013-12-311-4/+4
| |
* | Use literal for data lookupkpdecker2013-12-311-1/+1
| |
* | Add stack handling sanity checkskpdecker2013-12-311-0/+8
| |
* | Fix stack id "leak" on replaceStackkpdecker2013-12-311-1/+6
| |
* | Fix incorrect stack pop when replacing literalskpdecker2013-12-311-2/+4
| |
* | Fix multiple hash handling in subexpressionskpdecker2013-12-311-1/+5
| |
* | Added support for subexpressionsmachty2013-12-301-22/+20
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Handlebars now supports subexpressions. {{foo (bar 3)}} Subexpressions are always evaluated as helpers; if `3` were omitted from the above example, `bar` would be invoked as a param-less helper, even though a top-levell `{{bar}}` would be considered ambiguous. The return value of a subexpression helper is passed in as a parameter of a parent subexpression helper, even in string params mode. Their type, as listed in `options.types` or `options.hashTypes` in string params mode, is "sexpr". The main conceptual change in the Handlebars code is that there is a new AST.SexprNode that manages the params/hash passed into a mustache, as well as the logic that governs whether that mustache is a helper invocation, property lookup, etc. MustacheNode, which used to manage this stuff, still exists, but only manages things like white-space stripping and whether the mustache is escaped or not. So, a MustacheNode _has_ a SexprNode. The introduction of subexpressions is fully backwards compatible, but a few things needed to change about the compiled output of a template in order to support subexpressions. The main one is that the options hash is no longer stashed in a local `options` var before being passed to either the helper being invoked or the `helperMissing` fallback. Rather, the options object is inlined in these cases. This does mean compiled template sizes will be a little bit larger, even those that don't make use of subexpressions, but shouldn't have any noticeable impact on performance when actually rendering templates as only one of these inlined objects will actually get evaluated.