What is FMPP?
FMPP is a general-purpose text file preprocessing tool that uses FreeMarker templates. It process entire directories recursively. It can be used for generating complete static websites, source code, configuration files, etc. It can insert data from sources like CSV, XML, and JSON into the generated files. (You can add new kind of data sources in Java.) See the Tutorial for a more concrete introduction.
FMPP can be used with UN*X-style command-line interface, or as Ant task, or can be embedded into your application using its Java API.
FMPP was written in Java, thus it runs on all modern platforms (Windows, "Linux", OS X, etc.).
FMPP is Free software under Apache License 2.0. See license...
Features
A quick list of FMPP capabilities:
- FreeMarker as the preprocessor language:
- All the usual template constructs, such as include, if/else/elseif, loop.
- Macros with named arguments and nested content (body).
- Variables (global, or local for a macro call)
- Complex expressions using string, arithmetical and logical operations. Extensible with custom functions.
- Automatic and manual escaping (HTML, XML, custom function)
- Transforming (filtering) blocks of output; extensible with custom transformations in Java.
- Capturing block of output into a variable.
- Charset aware, internally uses UNICODE.
- Number and date/time formatting with masks (patterns). Locale sensitive formatting.
- Process entire directories recursively.
- Different file processing mode can be chosen for each file, based on path patterns (as file extension): execute file as template, or parse it as XML and then render it to output with a template, or binary-copy it, or ignore it.
- Can ignore bad source files and log the error message into a text file.
- Can guarantee that certain files will be processed later than others.
- XML file
- CSV and tab-separated text file
- JSON file
- Java "properties" file
- Ant properties, Ant project and target information
- System clock
- Plain text file
- Output splitting: a single source file can generate multiple output files (including 0 output files).
- Automatic file inclusion, automatic escaping, and whatnot that can be done with automatically inserted headers and footers, chosen based on path patterns.
- Generate HTML <img>-s with calculated width and height.
- Calculate the relative path to the home directory, or to any other file.
- Rendering (transforming) XML files with FreeMarker templates. (Similar to the typical XSLT usage pattern.)
- Query the size/existence of source files.
- Query output encoding (charset).
- URL-escaping (with the actual output charset).
Documentation
This on-line documentation is for FMPP version 0.9.16 + FreeMarker 2.3.28.
The full documentation of the version you are using can be found in the docs
directory of the installed FMPP.
Download
The latest released version is FMPP 0.9.16 (comes with FreeMarker 2.3.28, but you can replace it with a later version).
Downloads include "binaries", all documentation, and source code.
Change log (version history)...
FMPP is a Java application so it requires Java to be installed on your machine (version 5 or later).
The FMPP Apache Ant task (optional, seldom used nowadays) requires Ant 1.5.1 or later.
For text editor and IDE plug-ins and other FreeMarker template-related tools, please visit the FreeMarker homepage: https://freemarker.apache.org/
Project history and status
FMPP was mostly written in 2003 (so it predates Java generics, Maven-like dependency management, etc.), by a single guy (me), to automate some tasks at work. The code/design of my 15+ year younger myself (and of the era maybe) is funny/WTF at places, but it works, doesn't cut any corners, and was used quite heavily by many.
The project is in maintenance mode, but check the version history to see if it's still maintained. If you hit some blocker problem, it's likely that I will fix it and do a release.
Contact
Help: Ask on Stack Overflow with "fmpp" tag.
Suggestions: Use the Feature Request tracker, or write to ddekanyREMOVETHIS@freemail.hu (delete the "REMOVETHIS"!)
Please report bugs and documentation mistakes you find on the bug tracker or to ddekanyREMOVETHIS@freemail.hu (delete the "REMOVETHIS"!)!
Report FreeMarker bugs on the FreeMarker bug tracker, not on the FMPP bug tracker. (If you are not sure which is it, then just report on any of them.)