/temma

Temma - HTML + Perl template processor

Primary LanguagePerl

NAME

Temma - An HTML + Perl template processor

SYNOPSIS

<!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>

DESCRIPTION

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.

MODULES AND DOCUMENTS

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.

DESIGN GOALS

Requirements

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.

Author-friendliness.

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.)

Design restrictions

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.

DEPENDENCY

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

<https://github.com/manakai/perl-web-encodings>

web-dom

<https://github.com/manakai/perl-web-dom>

web-markup

<https://github.com/manakai/perl-web-markup>

Although not required, some of features depend on Path::Class.

HISTORY

The Git repository was at <https://github.com/wakaba/temma> until 19 November 2023, then transferred to the manakai project.

AUTHOR

Wakaba <wakaba@suikawiki.org>.

LICENSE

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.