2.0 - Apache FreeMarker Manual

Unsupported web browser - Use a modern browser to view this website!

- Home
- Manual
- Java API

- Contribute
- Report a Bug
- Download

Manual
Previous Next

# 2.0

FreeMarker 2.0 final was released on 18 April 2002. The changes with respect to the previous release, 2.0 RC3 are fairly minor.

## Bugfixes

- There were a couple of bugs in handling null values, where Lazarus did not do the same thing as FreeMarker Classic. Traditionally, in FreeMarker, nulls were treated as being equivalent to an empty string in the appropriate context. At this point, to the best of our knowledge, there is backward compatibility with FreeMarker Classic in this respect.

- Literal strings can now include line breaks. This was a backward compatibility issue with FreeMarker Classic that has been fixed.

## Changes to the Template language

- You can use the extra built-in of `myString?web_safe` to convert a string to its "web-safe" equivalent, where problematic characters such as '<' are converted to &lt;.

- In displaying numbers with a fractional part, the rendering apparatus now respects the decimal separator of the template's locale, so that, for example, in continental Europe, you would see 1,1 and in the U.S. locale, 1.1.

## Changes to the API

- The `getAsString()` method in the `TemplateScalarModel` interface now takes a `java.util.Locale` as a parameter. For the most part, this is a hook for later use. In the default implementation, `SimpleScalar`, this parameter is unused. If you are implementing this interface yourself, your implementation may ignore the parameter. However, it will be appealing for certain implementations.

- The constructors of `FileTemplateCache` have changed. If you are using an absolute directory on the file system as the location of your templates, you need to pass in an instance of `java.io.File` to indicate the location. If you use the constructors that take a string, this is taken to mean relative to the classloader classpath.

## Miscellany

The ant build script build.xml now contains a target that builds a .war file containing the Hello, World and Guestbook examples. It builds a fmexamples.war. For example, if you are using Tomcat in its out-of-the-box configuration, you would place this under <TOMCAT_HOME>/webapps and then you would use http://localhost:8080/fmexamples/servlet/hello and http://localhost:8080/fmexamples/servlet/guestbook for the Hello, World and Guestbook examples respectively.

Previous Next