java.lang.String is immutable and cannot be overwritten by user.
When passing sensitive data as context variable String remains in memory until GC removes it.
CharSequence allows user to provide his own implementation and overwrite data as needed.
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.
Me, on the blackboard:
"I will not optimize code without using a profiler."
"I will not optimize code without using a profiler."
"I will not optimize code without using a profiler."
"I will not optimize code without using a profiler."
"I will not optimize code without using a profiler."
...
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.
Section behavior used to be somewhat hackily determined from nullValue and
defaultValue, but it was messy. Now it has its own configuration and things are
more explicit.
Previously missing/null sections were treated as false, but if you set
nullValue to something, then missing sections became an error, but null
sections remained false. If you set defaultValue to something, missing sections
went back to being omitted. Kooky.
Now missing sections are omitted, unless you set strictSections to true, in
which case they become an error. nullValue and defaultValue have no impact on
section behavior.
There is no way to make null sections an error, but I don't see any demand for
that, so I'm going to leave that as a TODO.
Closes#60.
Mainly we also needed to trim around comment tags, but also there were a bunch
of tricky edge cases that were only partially addressed. This is some edgy
business!
Fixes#39.
This fixes a bug where falsey values were not properly triggering inverted
sections, and consolidates some logic.
Also did some renaming. Couldn't help myself.
In javascript implementation, zero is a falsy value and is treated as a false boolean.
An option is added (false by default) to treat zero as a falsy value as in javascript implementation.
It means that section like:
{{#zeroValue}}foo{{/zeroValue}}
will not be rendered.
- triple-stache mode reverted to only work with {{{ }}} rather than working
with whatever default delims you set; I think this is more in the spirit of
the Mustache spec
- Compiler.withDelims takes a delims string rather than the internal Delims
class which callers don't care about or have access to
- nixed Delims constructors, made updateDelims fluent
- nixed DelimsTest, it wasn't testing anything that wasn't also already tested
by the functional tests in MustacheTest