Commit Graph

72 Commits

Author SHA1 Message Date
kpdecker cb51b82b8e Add support for dynamic partial names
Uses the subexpression syntax to allow for dynamic partial lookups. Ex:

```
{{> (helper) }}
```

Fixes #933
2015-01-18 13:23:45 -06:00
kpdecker 6650957f79 Implement strict and assumeObject modes
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
2014-12-27 14:59:36 -06:00
kpdecker 396795c983 Implement block parameters
Fixes #907
2014-12-26 00:31:57 -06:00
kpdecker f990cf0064 Treat partial exec in a manner closer to helpers
This helps unify the code handling and will also be needed to support string/id tracking on partials.
2014-11-27 09:11:03 -06:00
kpdecker 617dd57162 Lookup partials when undefined 2014-11-25 23:15:11 -06:00
kpdecker 4a2afa9d02 Propagate options for client compiled partials
Fixes #901
2014-11-08 19:06:40 -06:00
kpdecker ca1486b960 Prune unused code 2014-08-25 22:39:17 -05:00
kpdecker 84342b6215 Add template isTop flag 2014-08-25 21:15:26 -05:00
kpdecker 501a640330 Allow passing depths to _child 2014-08-25 00:32:57 -05:00
kpdecker 2b3fdf7ea8 Additional test coverage cleanup
Also fixes the template._child implementation which broke with the depthed work.
2014-08-23 18:52:30 -05:00
kpdecker 084e8fe1b7 Provide better error on unexpected template
Fixes #806
2014-08-15 00:06:40 -05:00
kpdecker cb22ee5681 Increase test coverage a touch 2014-08-14 12:25:35 -05:00
kpdecker 9f8110fe15 Implement partial recursive lookup 2014-08-14 00:29:25 -05:00
kpdecker 0edce6e1d1 Inherit compat flag for partials 2014-08-14 00:29:25 -05:00
kpdecker c98613b711 Implement recursive field lookup in compat mode
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.
2014-08-13 20:46:42 -05:00
kpdecker 625b00e1da Avoid depth construction overhead for non-depthed 2014-08-13 14:51:33 -05:00
kpdecker b695aaec7c Use depths array rather than passing array args
Approximately doubles the throughput performance of depthed templates and clears the way for doing recursive path lookups in pathed mode.
2014-08-13 14:11:53 -05:00
kpdecker e93d516672 Render indent for standalone partials 2014-08-12 14:41:58 -05:00
kpdecker 4aad72d223 Move lambda resolution to runtime
This has a very positive impact on precompiled output size, particularly for known-helpers cases, and little or no impact on the throughput numbers.
2014-07-06 12:53:01 -05:00
kpdecker 085e5e1937 Refactor template init logic 2014-04-13 07:21:08 -05:00
kpdecker c72a8d5e84 Add child accessor API 2014-02-09 22:48:38 -06:00
kpdecker 16f135835e Add support for depthed resolution of data fields 2014-02-09 18:35:22 -06:00
kpdecker 2812fe2775 Convert template spec to object literal
This allows for metadata to be associated with the template and a simplification of the template init logic.
2014-02-06 23:05:45 -08:00
kpdecker cea57c05e2 Optimize initData for root defined case 2014-01-18 09:23:11 -06:00
kpdecker 45ae86a248 Implement partial hash evaluation 2014-01-17 17:51:52 -06:00
Blake Embrey 13633e7896 Improve usefulness of extend util, properly use namespace property, update setup options to use a hash helper. 2014-01-16 21:24:26 +10:00
kpdecker f650b0d69e Expose the initial context via @root 2014-01-15 09:41:53 -06:00
kpdecker 6e4e1f8404 Include line info in compiler thrown exceptions
Fixes #636
2014-01-01 19:14:51 -06:00
kpdecker bbc7c7d080 Expose compilerInfo and checkRevision as APIs
Fixes #656
2013-12-23 21:00:59 -06:00
kpdecker abe9c82e75 Use env.VM to lookup runtime methods
Allows for overrides by 3rd parties

Fixes #679
2013-12-23 19:53:11 -06:00
kpdecker 93fb25c702 Handle empty responses from partials
Fixes #675
2013-12-23 15:33:33 -06:00
kpdecker f17cb3ecac Run jshint on output
Allows us to execute jshint in non-forced mode.
2013-12-01 15:40:08 -06:00
kpdecker 15500aef70 Access utils methods via modules
Allows for monkey patching (under ES5 systems). This somewhat mirrors
the proposed behavior in https://github.com/square/es6-module-transpiler/issues/37
but applies the behavior via manual code changes rather than compiler
support.
2013-10-14 11:50:18 -05:00
kpdecker 9769045e04 Cleanup unused var warnings 2013-10-09 03:53:09 -07:00
kpdecker b6c9f85d22 Use template env and compile methods 2013-10-09 03:20:22 -07:00
Alex Navasardyan 19f1a1f81d fixing jshint errors 2013-10-04 14:28:05 -04:00
kpdecker 6a23391a9a Break exception class out into a standalone module 2013-10-01 21:14:18 -05:00
kpdecker 1e8409efa6 Fix merge errors 2013-09-02 18:25:03 -05:00
kpdecker cb0c45b29f Merge branch 'master' into es6-modules
Conflicts:
	Gruntfile.js
	Rakefile
	dist/handlebars.js
	dist/handlebars.runtime.js
	lib/handlebars.js
	lib/handlebars/base.js
	lib/handlebars/runtime.js
	lib/handlebars/utils.js
	package.json
2013-09-02 18:19:18 -05:00
kpdecker 4c02d3027c Optimize partial helper/partial merge handling 2013-08-24 19:52:22 -05:00
Yehuda Katz 5f664dd78b Make the Handlebars environment into an object
The idea is that the environment wraps up the mutable stuff in
Handlebars (like the helpers) and that you could theoretically create a
new one at any time and pass it in to Handlebars.template.

Every test makes a new environment and uses it in template compilation.
2013-07-26 16:50:37 +00:00
Yehuda Katz f5c8484ea0 Further progress towards modularization.
At this point, I have only 2 fails in the Node build, but I'm doing a
bunch of manual stuff locally and still have a bunch of hacks.
2013-07-24 05:03:27 +00:00
Yehuda Katz 88ee4757e7 Initial work on ES6 modules 2013-07-01 13:59:58 -07:00
kpdecker 16fd601a5c Merge global and passed helpers and partials 2013-05-31 13:12:06 -04:00
kpdecker baccdb4cfc Add program metadata
Include program id and depth on the generated wrapper objects. This
allows helpers who are passed these objects to differentiate between
helpers for cases where they may want to cache the generated DOM
structure.
2013-02-17 04:27:42 -06:00
Tommy Messbauer 1ca7462497 merge 2013-02-11 23:00:47 -06:00
Peter Wagenet 7c633b604d Better error messages for precompiler runtime mismatch 2013-02-09 19:25:53 -08:00
Peter Wagenet 51e9259fac Decouple compiler version checks from release versions 2013-02-08 18:42:20 -08:00
Peter Wagenet 6fe7f17c89 Improved precompile template version check
This check reduces duplicated code as well as also failing if the
template was precompiled on a version before the check was added.
2013-01-30 22:44:30 -08:00
Tommy Messbauer db975b42a0 Merged upstream master and ran unit tests 2012-11-26 10:26:15 -06:00