Temma - An HTML + Perl template processor
<!DOCTYPE html>
<html lang=en t:params="$app">
<title t:parse><t:text value=" $app->title ">
<h1><t:text value=" $app->title "></h1>
<ul>
<t:for as=$item x=" $app->items ">
<li><a pl:href=" $item->url "><t:text value=" $item->title "></a>
</t:for>
</ul>
Temma is a template processing engine for genearating HTML or plain text documents. It converts a template document written in Temma markup language, with zero or more parameters, into an HTML document, HTML fragment, or plain text.
Temma::Language - A documentation for the Temma markup language.
Temma::Parser - A parser to convert a textual representation of Temma template document into its DOM representation.
Temma::Processor - A processor to convert the DOM representation of a Temma template document into result HTML/plain text document.
- Syntax-awareness.
-
The processor must understand the document format (e.g. HTML) such that it can encode data appropriately as required by the context. In other words, it can't require authors to HTML-escape all text fragments to embed into the document. The processor must support at least HTML and plain text formats.
- Streamability.
-
It must be possible for the processor to generate the output incrementally.
-
The format should not force authors to learn stupid custom language to access data from outside of the template. It may embed Perl code for that purpose.
- Easyness-to-write.
-
The format should not be so verbose. Authoring of documents in the format should be as easy as HTML, and must be much more easy than XML.
- Error tolerance.
-
The processing must be error tolerant. A small error should not abort the entire process. Error handling must be explicitly performed such that authors can predict what will happen if something unexpected has occurred.
- Internationalization.
-
The format should be well-integrated with internationalization framework. In particular, it should provide convinience way(s) to reference texts in text catalog for the currently-selected language. However, it must not force the application to use any specific internationalization framework.
It is not required for the processor to always generate conforming HTML document. It's template author's (or, in fact, application's) responsibility to ensure the result document being conforming. (It does not mean it should be more easy for authors to generate non-conforming documents than to generate conforming documents.)
- Reusability of HTML/XML tokenizer.
-
Don't introduce custom syntax at tokenization stage.
- DOM compatibility.
-
A document must be fully representable as a DOM tree. Note that the document format don't have to be able to represent any possible DOM tree.
- No parser-level script execution.
-
No Perl (or any other programming language) code should be executed until the DOM tree is completely constructed by the parser.
Temma requires Perl 5.14.2 or later. In addition, it is built on top of following packages, which are registered as submodules of the Temma repository:
- web-encodings
- web-dom
- web-markup
Although not required, some of features depend on Path::Class.
The Git repository was at <https://github.com/wakaba/temma> until 19 November 2023, then transferred to the manakai project.
Wakaba <wakaba@suikawiki.org>.
Copyright 2012-2023 Wakaba <wakaba@suikawiki.org>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.