MiniTemplator
MiniTemplator is a compact, optimized template engine for HTML files.
Features
- Available for JavaScript, Java, PHP and Visual Basic (VB/VBA).
- Simple syntax for template variables and blocks.
- Blocks can be nested.
- A template can be parsed once and used many times.
- Open Source
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 -->
Conditional statements (only implemented in the JavaScript and Java versions):
<!-- $if condExpr -->
...
<!-- $elseIf condExpr -->
...
<!-- $else -->
...
<!-- $endIf -->
JavaScript Version
NPM package
minitemplator
Source code repository
GitHub
Java Version
Documentation
API
documentation (javadoc)
Example programs
Download
MiniTemplator-java.zip
(whole package, including API documentation and sample programs)
Source code repository
GitHub
PHP Version
Documentation
API documentation (phpdoc)
Example programs
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
Example programs
Download
MiniTemplator_vbasic.zip
(whole package, including API documentation and sample programs)