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."
...
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.
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.
This allows one to have a map with keys like "foo.bar.baz" even when not in
standards mode. If a whole key is missing, then we attempt to decompose it and
look it up piecewise.
Closes#55.
That's what collectors are for. This also avoids the needless expense of doing
Integer.parseInt on every single key (the vast majority of which will not
actually be numbers), every single time we do a context lookup.
The groups with failing tests are currently commented out (everything except
interpolation). The main reason for failures are due to the requirement that
standalone lines that contain nothing but whitespace be stripped from the
output.
Solving need to distinguish context errors from environment errors.
The exception has fields for the offending key and line number. This
is a first step towards internationalization of messages.
If Compliler.nullValue contains a substring "{{name}}", then this substring
will be replaced with the name of variable.
For example, if nullValue="?{{name}}?" and variable is resolved to null,
then string "?foo?" will be used.
Kali/Bertrand convinced me that being consistent with other Mustache
implementations is more important than whatever wacky reasons I was harboring
for keeping compound variables different than singleton sections.
a pluggable component.
This allows scaling down to the GWT environment by hiding the reflection code
via GWT's super source mechanism.
And it allows scaling up to non-Java languages (like Scala) by allowing the
library client to extend the DefaultCollector and teach it about Scala
Iterators, Iterables and Maps.
I also just realized that GWT has no facilities for Reader and Writer, which is
going to complicate making things work in GWT even further. But for now, I'll
just leave things as is.
for use when variables resolve to null, but still wishes for exceptions to be
thrown when values are not resolvable (i.e. are typos). Pre-existing behavior
is preserved if one uses defaultValue() or does not change the default
configuration.
Nota bene: there are complexities, so be sure to read the documentation.
rather than "missingVariableValue" because the value is used any time a
variable resolves to null, not necessarily just when it is missing. If you
have a context like:
new Object() {
String foo = null;
}
and reference {{foo}} in your template, foo is not missing, per se, but the
default value will still be used for it.