HOME

TheInfoList



OR:

Apache FreeMarker is a
free Free may refer to: Concept * Freedom, having the ability to do something, without having to obey anyone/anything * Freethought, a position that beliefs should be formed only on the basis of logic, reason, and empiricism * Emancipate, to procur ...
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
-based template engine, originally focusing on dynamic web page generation with
MVC MVC may refer to: Science and technology * Maximum-value composite procedure, an imaging procedure * Multivariable calculus, a concept in mathematics * Multivariable control, a concept in process engineering * Mechanical vapor compression, a desal ...
software architecture Software architecture is the fundamental structure of a software system and the discipline of creating such structures and systems. Each structure comprises software elements, relations among them, and properties of both elements and relations. ...
. However, it is a general purpose template engine, with no dependency on
servlet A Jakarta Servlet (formerly Java Servlet) is a Java software component that extends the capabilities of a server. Although servlets can respond to many types of requests, they most commonly implement web containers for hosting web application ...
s or
HTTP The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, ...
or
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
, and is thus often used for generating source code, configuration files or e-mails.


History

FreeMarker had a somewhat hectic history until about 2004, caused by
paradigm shift A paradigm shift, a concept brought into the common lexicon by the American physicist and philosopher Thomas Kuhn, is a fundamental change in the basic concepts and experimental practices of a scientific discipline. Even though Kuhn restricted t ...
s and other significant changes on multiple occasions. FreeMarker 1 (now known as FreeMarker Classic, a separate project) was originally written by Benjamin Geer and Mike Bayer. From 2002, the new project lead was Jonathan Revusky, who released FreeMarker 2, which started a sequence of several substantial changes. The main goal of the changes was to make the template language more strict, i.e., to detect as many of the typos and other typical mistakes as possible. Also, automatic object wrapping was introduced, along with gradual advancement of the type system of the template language. The language has gained many power-user features, such as more powerful macro programming capabilities and namespaces. The language has reached a quite settled state with version 2.3, released in 2004 Q3. As of 2016, the product has remained backward compatible. No significant backward incompatible changes are expected in the FreeMarker 2 series in the future. In late 2015, FreeMarker was granted to the
Apache Software Foundation The Apache Software Foundation (ASF) is an American nonprofit corporation (classified as a 501(c)(3) organization in the United States) to support a number of open source software projects. The ASF was formed from a group of developers of the A ...
, where it has entered the
Apache Incubator Apache Incubator is the gateway for open-source projects intended to become fully fledged Apache Software Foundation projects. The Incubator project was created in October 2002 to provide an entry path to the Apache Software Foundation for projec ...
, and in 2018-03-21 it has become a fully accepted Apache project.


Example

The following template:

Hello $! You have the following messages: <#list messages as m>

$: $

processed by FreeMarker will produce something like:

Hello Joe! You have the following messages:

Tim: Please don't forget to bring the conference papers!

Cindy: Can you give me a visit this afternoon?

Richard: Don't forget the papers this time!

Variables like "name" and "messages" are coming from outside the template, and thus the template author has to deal with the presentation issues only. The template remains the same regardless if these variables are coming from a database or from a cookie or calculated in whatever other ways. Also the exact Java
API An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standa ...
(and hence the class) of the values can be hidden in FreeMarker using a technique called object wrapping. For example, "messages" seems to be a list or array of
JavaBeans In computing based on the Java Platform, JavaBeans is a technology developed by Sun Microsystems and released in 1996, as part of JDK 1.1. The 'beans' of JavaBeans are classes that encapsulate one or more objects into a single standardized objec ...
that have "from" and "body" properties, but it might as well be something very different, and the template is not affected (as long as a proper object wrapper is used).


See also

* JSP *
Apache Velocity Apache Velocity first released in April 2001, is a Java-based template engine that provides a template language to reference objects defined in Java code. It aims to ensure clean separation between the presentation tier and business tiers in a W ...
*
Thymeleaf Thymeleaf is a Java XML/XHTML/HTML5 template engine that can work both in web (servlet-based) and non-web environments. It is better suited for serving XHTML/HTML5 at the view layer of MVC-based web applications, but it can process any XML file e ...


External links

* {{Apache Software Foundation Java enterprise platform Template engines