Commit Graph

13 Commits

Author SHA1 Message Date
Peer Schönhusen 979b3b887c Add indentation to partials 2023-11-15 11:24:40 +01:00
Michael Bayne ca08cdb1a4 Tests for some first/last stuff.
From @spacether.
2021-02-04 13:20:00 -08:00
Michael Bayne 9508731dfa Add a test for recursive partial expansion.
This pertains to issue #124, but it seems to work fine.
2020-11-03 11:15:00 -08:00
Michael Bayne 4533567303 Fix bugs relating to . and this.
First, I missed some reference checks when I stopped interning names. Fixed
those.

Second, when iterating over an array which contained null elements, the wrong
thing was happening.
2018-06-04 16:10:35 -07:00
Michael Bayne 37e31cbeac Add mechism to visit template tags.
This is useful when you want to inspect the structure of the template without
executing it.
2017-12-17 15:16:09 -08:00
Michael Bayne 02f917e2f7 Add Fragment.executeTemplate().
Allows a lambda to execute a template in the lambda's own context. This enables
'late bound' template inclusion where the lambda can select a template based on
dynamic data in the context at the time it is executed.

Closes #92.
2017-12-03 18:29:15 -08:00
Michael Bayne 8cddc839e3 Oops can't use reflection in shared tests. 2017-09-20 09:51:53 -07:00
Michael Bayne 172f35fb64 When nesting for non-list contexts, inherit list info.
This ensures that if you enter a conditional block while inside a list
block, the list "state" from the outer list will still be visible. For
example (somewhat contrived, but gets the point across):

{{#list}}
{{#name}}{{-index}}. {{.}}{{/name}}
{{^name}}{{-index}}. No name!{{/name}}
{{/list}}

Yields something like:

1. Bob
2. Mary
3. No name!
4. Jim

Fixes #90.
2017-09-20 09:43:14 -07:00
Michael Bayne 96d9ba5e24 Some test fiddling to make things work in GWT. 2016-08-08 09:12:04 -07:00
Michael Bayne 9bb842ed20 Special case 'entrySet' on Map fetcher.
You can't normally reflectively access methods on Map because it has a
special fetcher, but being able to reflectively access 'entrySet' is
super useful when you want to iterate over the keys+values of a map, so
we're going to hack it in there. Ha!
2016-06-15 11:51:44 -07:00
Michael Bayne 546f78318e Simple support for decompiling fragments.
There are limitations! See the javadoc for Template.Fragment.decompile.

Closes #75.
2016-04-14 08:32:07 -07:00
Michael Bayne 9eda17f85b Escape ` and = when escaping HTML.
They can be used for nefarious purposes on old IEs.

Refs wycats/handlebars.js@83b8e84
2015-12-24 13:48:07 -08:00
Michael Bayne cbd80d1d08 Big test revamp to get tests running in GWT.
For some reason I sort of blocked from my mind the fact that none of the actual
tests were running in GWT. Really I was just testing that things compiled.

So now the tests actually run in GWT. This means I had to split the tests that
rely on method/field lookup via reflection into a separate file because that
stuff will never work with GWT. I also changed a bunch of the other tests not
to surreptitiously use reflection because they were ostensibly testing
something else, so no point in those tests being GWT-incompatible just for
kicks.

This also means we can't use JUnit 4 annotations (sigh, I wish GWT would step
out of the stone age, but that's a whole other fiasco that I don't even want to
think about). So some of the tests that were using @Test(expected=FooException)
had to be rewritten to manually catch the exception and fail if it was not
thrown.

Anyhow, now most of the tests are in fact running in GWT (when you do "mvn
integration-test") and the test that I expected should fail in GWT is in fact
failing. Yay!
2015-09-21 15:43:48 -07:00