ZOGAN: PHP template engine for XML

Haruki Setoyama

Legal Notice

$Id: zogan.manual.xml,v 1.8 2004/10/18 09:17:29 haruki Exp $

Table of Contents

1. Introduction
1.1. What is ZOGAN?
1.2. Presentation?
1.3. Features
1.4. Requirements
1.5. License
1.6. Download
1.7. Install
2. Quick start guide
2.1. Hello World
2.2. List
2.3. Table
2.4. Modify attributes
3. Convert of special characters to XML entities
4. Getting displayed text into PHP variable
5. Direct declaration of hash
6. Object as data
6.1. Substitute of hash
6.2. Data itself
7. Syntax for conditional
7.1. Content of element
7.2. Attribute
8. Omission of tag or element
8.1. 'omit-tag' attribute
8.2. 'omit' attribute
9. Display alternately
10. Processing data in template with function
10.1. Built-in functions
10.2. User defined functions
11. Number label
12. Inclusion of other templates
13. For debugging
13.1. Comment
13.2. Debug information
14. Namespace URI for ZOGAN
15. Permitted characters
16. API and Other examples

1. Introduction

1.1. What is ZOGAN?

ZOGAN is a template engine for XML (such as XHTML) with PHP, that embeds data in PHP variable into a template in the form of XML.

Template engine makes it possible to separate XML presentation from programming code, and presentation structure from presentation logic. The separation makes your code easy to understand and to edit.

I have got the concept of this template engine thanks to Amrita template library that is for Ruby.

1.2. Presentation?

Presentation is the part where an application presents information for its user. Here I classify presentation into three parts, which are “structure”, “design” and “logic”. For example, XHTML has charge of presentation structure, CSS does of design, and PHP itself should take charge of logic. So ZOGAN template engine does not have complicated control stricture like 'if ... then ...'.

Separation of presentation from main processing makes it possible and easy for designers and programmer to work on their own file separately. But the three parts depends on each other to some extent, so plenty of communications between them are necessary.

1.3. Features

  • Templates for ZOGAN are and must be well-formed XML documents.

  • ZOGAN uses tag attributes with a namespace ("var" as default) to specify instructions for template.

  • So, the templates are expected to be written using normal XML or XHTML editor.

  • Model data to display with the templates is a nested hash.

  • The templates will be compiled into PHP code before display for speed.

1.4. Requirements

1.5. License

the GNU Lesser General Public License version 2.1 , or any later version.

1.6. Download

ZOAGN belongs to a sourceforge.jp project called PHPOOT . Download latest ZOGAN from there.

1.7. Install

Use PEAR installer. For example,

pear install zogan-0.2.tgz