Products
Snippets & Tips
source-code.biz

MiniTemplator

MiniTemplator is a compact template engine for HTML files.

Features

  • Available in Java, PHP and Visual Basic (VB/VBA).
  • Simple syntax for template variables and blocks.
  • Blocks can be nested.
  • Compact, well-documented source code. A single code module.
  • Documentation and sample programs available.
  • Open Source and Free Software. Licensed under the GNU LGPL.
    (The Java version is also licensed under the EPL).
    It may be used freely, even for commercial projects (Details).

What is a Template Engine?

Diagram

A template engine is a software module which is used to generate HTML pages (or other text files). The layout of a HTML page is defined within a template file, which can be designed by using a standard HTML editor like FrontPage. At run-time, the application program instructs the template engine to load the template, fill in variable values, repeat blocks and produce the final HTML page.

Why use a Template Engine?

The advantage of using a template engine, instead of embedding program code and HTML code, is:

  • Program code and web page layout are separated and can be designed and modified independently.
  • A software developer and a web page designer can work together without interfering in each others work. Responsibilities can be split.
  • After the program has been finished, the page layout can be modified at a later time, without having to modify the program code.
  • Templates are useful when web pages will be translated, and multiple languages must be supported by the same program.

Why use MiniTemplator?

What is special about MiniTemplator, compared to other template engines?

  • There are other template engines (like Velocity, WebMacro or Smarty) which are huge and use complex template syntaxes. These template syntaxes are so complex that they are almost like new programming languages. MiniTemplator however uses a very simple template syntax. All processing (loops, if-then-else logic) and variable formatting is done in application program code (Java/PHP/VB), which leads to better separation of layout and code, and no new complex syntax has to be learned.
  • There are simple template engines which do not provide elementary features (like nested blocks, loading the template from a string, or storing the output into a string variable), or are slow. MiniTemplator provides these elementary features and is fast, because the template is only parsed once (at the time it is loaded).
  • MiniTemplator provides the features to build professional web applications, and it is compact and fits within a single code module.

MiniTemplator Template Syntax

A simple syntax is used to define variables and blocks within the template. This syntax is compatible with HTML editors like FrontPage, but it can also be used for non-HTML files.

Variables:

${VariableName}

Blocks:

<!-- $BeginBlock BlockName -->
... block content ...
<!-- $EndBlock BlockName -->

Include a subtemplate:

<!-- $Include RelativeFileName -->

Price

MiniTemplator is free. But if you wish to express your appreciation for the time I have expended developing it, I would appreciate a monetary donation.

Java Version

Documentation

   API documentation (in javadoc format)

Sample programs

 Sample1: Program Template
(HTML code)
Output Page
(web page)
Output File
(HTML code)
 Sample2: Program Template
(HTML code)
Output Page
(web page)
Output File
(HTML code)

Download

   MiniTemplator_java.zip (whole package, including API documentation and sample programs)

PHP Version

Documentation

   API documentation (in phpdoc format)

Sample programs

 Sample1: Program Template
(HTML code)
Output Page
(web page)
Output File
(HTML code)
 Sample2: Program Template
(HTML code)
Output Page
(web page)
Output File
(HTML code)

Download

   MiniTemplator_php.zip (whole package, including API documentation and sample programs)

Visual Basic (VB/VBA) Version

The VB-Version of the MiniTemplator is in VB6 format, but the VB-Module can also be used within a Microsoft-Access application, i.e. to produce static HTML pages from database content.

Documentation

   API documentation

Sample programs

 Sample1: Program Template
(HTML code)
Output Page
(web page)
Output File
(HTML code)
 Sample2: Program Template
(HTML code)
Output Page
(web page)
Output File
(HTML code)

Download

   MiniTemplator_vbasic.zip (whole package, including API documentation and sample programs)

Support, Bug Reports, Feature Requests, Old Versions

SourceForge Project Page

Jars-Logo