2.3.7 - FreeMarker Manual

- Home
- Manual
- Java API

- Contribute
- Report a Bug
- Download

Manual
Previous Next

# 2.3.7

Date of release: 2006-06-23

This release, compared to 2.3.7 RC1, contains new operators for handling null/missing variables, , the `substring` built-in, and some more bugfixes. Note that 2.3.7 RC1 has a long change log, so you may want to read that too.

## Changes on the Java side

- The `seq_contains` built-in now handles `TemplateCollectionModel`-s as well.

- Bug fixed: In 2.3.7 RC1 `FreemarkerServlet` has always died with `NullPointerException` during initialization.

## Changes on the FTL side

- 3 new operators were added for terser missing variable handling. These operators make the `default`, `exists` and `if_exists` built-ins deprecated. (The parser doesn't issue any warning messages when you use deprecated built-ins, and they are still working.):

  - `exp1!exp2` is near equivalent with `exp1?default(exp2)`, also `(exp1)!exp2` is near equivalent with `(exp1)?default(exp2)`. The only difference is that this new operator doesn't evaluate the `exp2` when the default value is not needed.

  - `exp1!` is similar to `exp1?if_exists`, also `(exp1)!` is similar to `(exp1)?if_exists`. The difference is that with this new operator the default value is an empty string and an empty list and empty hash at the same time (multi-type variable), while with `if_exists` the default value was an empty string and an empty list and empty hash and boolean `false` and a transform that does nothing and ignores all parameters at the same time.

  - `exp1??` is equivalent with `exp1?exists`, also `(exp1)??` is equivalent with with `(exp1)?exists`.

- New built-in: `exp?substring(from, toExclusive)`, also callable as `exp?substring(from)`. Getting substrings was possible for a long time like `myString[from..toInclusive]` and `myString[from..]`, but `myString?substring(from, toExclusive)` and `myString?substring(from)` has the advantage that it has an exclusive end, which is more practical. (Edit: Since 2.3.21 ranges are the preferred way again, as it has `myString[from..<toExclusive]`.) Sequence (list) slices still has to be get with the old syntax, since `substring` only applies to strings. Please note that the ``to'' parameter is 1 greater with this new builtin, as it is an exclusive index. Further difference is that the `substring` built-in requires that the ``from'' index is less than or equal to the ``to'' index. So 0 length substrings are possible now, but not reversed substrings.

- Bug fixed: [1487694] malfunction when the `recover` directive has no nested content

Previous Next