tomhuda
60040e60fb
Update specs and code so that the function passed to block helpers has the same API as regular compiled templates
2011-05-04 00:03:50 -07:00
tomhuda
c29223a98b
Update specs for change to template signature
2011-05-03 20:39:14 -07:00
tomhuda
5d99572006
Rename vm.js to compiler.js
2011-05-03 20:38:28 -07:00
tomhuda
d83e1c7484
Remove unnecessary original runtime implementation
2011-05-03 20:38:06 -07:00
tomhuda
9333d1210d
Add support for passing String parameters to helper
2011-05-03 19:30:32 -07:00
Yehuda Katz
3e5bc84058
Merge pull request #69 from rgrove/allow-hyphens.
...
Allow ids to contain hyphens. Fixes #36 .
2011-05-03 19:01:37 -07:00
Yehuda Katz
5d8480fa8a
Merge pull request #48 from jasondavies/master.
...
Fix multi-backslash escaping
2011-05-03 18:59:59 -07:00
Yehuda Katz
56b0ce56f8
Merge pull request #50 from emtrane/spec_patch.
...
Correct path to vm.js
2011-05-03 18:59:07 -07:00
Ryan Grove
b324d002ca
Allow ids to contain hyphens. Fixes #36 .
...
Previously, a mustache like {{foo-bar}} would generate a
parse error, which was a departure from the behavior of
other Mustache implementations.
2011-04-28 22:30:21 -07:00
Ryan Grove
b291a1ad8c
Add ", ', and / to the list of chars that need HTML escaping.
...
Previously, only < and > were escaped. This meant that any Handlebars
template that used user input in an HTML attribute value was wide open
to a trivial XSS exploit. Note that unquoted attribute values are still
open to attack, but this set of characters at least brings Handlebars in
line with other Mustache implementations and other template languages.
See the OWASP XSS prevention cheat sheet (rule #1 ) for the rationale
behind escaping these characters:
https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet
2011-04-25 11:15:53 -07:00
Ryan Grove
dec196b4d9
The "if" block helper shouldn't treat empty arrays as truthy.
...
Given the data {foo: []}, the following template previously considered
foo to be truthy when it shouldn't have:
{{#if foo}}
You should not see me!
{{else}}
You should see me!
{{/if}}
2011-04-20 16:56:37 -07:00
Ryan Grove
aba636ec38
Support multi-line comments.
...
{{!
Like this.
}}
2011-04-18 16:08:20 -07:00
Martin Davidsson
f368f9177c
Correct path to vm.js for case-sensitive filesystems
...
lib/Handlebars/vm.js -> lib/handlebars/vm.js
2011-03-05 21:10:18 -08:00
tomhuda
357710f136
Add support for block hashes and clean up mustache/program code
2011-03-04 15:10:22 -08:00
tomhuda
ca9b9671a5
Add Hash arguments to simple mustaches (TODO: add Hash args to block helpers)
2011-03-04 00:11:03 -08:00
tomhuda
e0aa705f71
Add support for hash args in the tokenizer and parser
2011-03-03 21:33:28 -08:00
tomhuda
51d2543ba1
Add support for {{foo.bar.baz}}
2011-03-03 20:08:28 -08:00
Jason Davies
e5899cad1e
Test multi-backslash-escaping
2011-02-28 22:28:11 +00:00
Jason Davies
0397f875c5
Merge branch 'master' of http://github.com/wycats/handlebars.js
2011-02-28 22:23:11 +00:00
tomhuda
32d7e52182
Helpers take precedence over context properties with the same name. This is useful in scenarios where your context object is inherited from another system (such as a framework or JSON API) that may contain properties that conflict with helpers you explicitly define.
2011-02-25 23:01:11 -08:00
Jason Davies
0d4d8813ac
Merge branch 'master' of http://github.com/wycats/handlebars.js
...
Conflicts:
lib/handlebars.js
test/index.html
2011-02-21 01:51:31 +00:00
tomhuda
2b319bef2f
Make the function passed to a block helper have an identical signature to top-level template methods
2011-02-14 16:05:01 -08:00
tomhuda
299a0e81e3
data is passed to block helpers
2011-02-11 20:11:23 -08:00
tomhuda
88e7003331
* Added a few public API methods to JavaScriptCompiler.prototype, so it can be subclassed.
...
* made it possible to define an alternate name lookup scheme (so that {{foo}} does not have to be
context.foo, but can instead be something like context.get('foo'))
* made it possible to substitute an alternate buffer instead of the default empty String and override how
the compiled template appends to the buffer
* Added the concept of template-local data. In order to enable template-local data, pass true
as the second parameter to the template compiler. Then, pass in the data as the fourth
parameter (context, helpers, partials, data). These signatures may change before the 1.0 release.
2011-02-11 17:03:12 -08:00
wycats
4d501b6613
Need to require timeout
2011-02-07 19:41:35 -08:00
Alan Johnson
ac4d34dbe3
Backed out function helpers.
2011-01-25 21:21:57 -05:00
Alan Johnson
9349d6df0e
Added test for undefined blocks - didn't matter though.
2011-01-25 19:58:39 -05:00
Raimonds Simanovskis
ada5a95f9c
improved "with" and "each" helpers to support function as argument
2011-01-23 11:55:48 +02:00
Alan Johnson
65b421ee4d
Merged
2011-01-22 10:30:44 -05:00
wycats
c19f06b4ee
Updated semantics
2010-12-29 19:20:03 -08:00
wycats
bf6c74aa83
Restructure things more simply
2010-12-29 18:21:43 -08:00
Raimonds Simanovskis
b319730031
improved "if" helper to support function as argument
2010-12-28 13:37:42 +02:00
wycats
72fa62529e
Merge branch 'master' of https://github.com/zaach/handlebars.js into zaach-master
2010-12-27 13:02:20 -08:00
wycats
d87ae129c0
Add a #with helper
2010-12-21 09:47:01 -08:00
wycats
fc0d721b96
Use pluggable logger rather the puts
2010-12-21 09:45:59 -08:00
Zach Carter
faea35f8fa
Merging with latest master
2010-12-20 02:25:25 -05:00
wycats
b418ef6eb2
Add optimized compiled version of handlebars, which should be significantly faster. Use Handlebars.VM.compile instead of Handlebars.compile to use the optimized version.
...
Major TODOS:
* clean up a bunch of code duplication in the compiler
* reorganize the compiler
* add support for debug symbols which would make it possible
to provide information about what part of the source caused
a runtime error.
2010-12-18 23:27:34 -08:00
wycats
e15d675a64
Everything is working now on the new VM except for partials and inverse sections
2010-12-15 23:42:53 -08:00
Zach Carter
97536f897e
Switch to Jison's lexer.
2010-12-14 19:07:05 -05:00
wycats
ec948c7382
Small restructuring. Have I mentioned how much I hate having to write modules that work in both CommonJS and the browser?
2010-12-12 13:33:17 -08:00
wycats
9fcd85bbac
Allow helperMissing to apply to simple mustaches (paves the way to support things like link_to in a Rails context)
2010-12-11 18:43:58 -08:00
wycats
62cea5b05e
Make sure rspec returns the right line number from library files
2010-12-11 18:29:05 -08:00
wycats
215754c268
Make helperMissing a built-in feature
2010-12-11 18:28:37 -08:00
wycats
5097c18912
Make it possible to register helpers and partials and then skip passing in the helpers or partials later
2010-12-11 18:10:56 -08:00
wycats
fdc8e425d0
Improve compiling infrastructure, and restore a bit of duplication in spec_helper to make debugging easier in test failures
2010-12-11 18:10:26 -08:00
wycats
4db1abcd74
Fix up the compilation process
2010-12-04 17:35:36 -05:00
wycats
f205cec745
Finish compatibility with the old handlebars:
...
* foo"bar" is an invalid param
* {{foo}}bar{{/baz}} is invalid
* fix a number of issues with inverse sections
* add partials
2010-12-03 16:49:04 -05:00
wycats
9a6f77af56
A few more lingering bugs:
...
* add helperMissing.not to the specs
* add Handlebars.Utils.isEmpty
* add runtime handling for inverse sections
* fix __get__ to pass an IdNode to evaluate
* handle case in wrapProgram where context is undefined
2010-12-03 01:39:00 -05:00
wycats
c89ecf80a5
Inverse should really be its own node, as it has totally different runtime semantics
2010-12-03 01:10:14 -05:00
wycats
8f6f3051e6
Add support for inverted sections in the parser
2010-12-03 00:54:18 -05:00