Tazuna Website Builder
Previous: Installation ----- Contents: Contents ----- Next: Creole Markup

First Tazuna Web Site

Creating a Project

  1. Open a command line window and switch to your Tazuna directory.
  2. Type java -jar tazuna.jar -c simple testproject
  3. Type java -jar tazuna.jar testproject
  4. Look into testproject/out directory.

The whole project structure should look like this:

+ testproject/
  + in/
    - private_scripts/
    - style/
    - index.cnt
    - index.tpl
  + out/
    - style/
    - index.html

The first command creates a new project named testproject from a template named simple. The simple template is provided by Tazuna.

The second command builds the project. Tazuna looks into the in directory and tries to find a template file (.tpl) for every content file (.cnt). If Tazuna finds a template file, it inserts the content into the template and writes the result to the out directory. Other files are just copied into the out directory.

Let's have a look at the input files.

File: index.tpl

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>No Title</title>
<link rel="STYLESHEET" type="text/css" href="$teHome/style/simple.css" title="Simple Style">



This file is a template for a simple HTML page. It contains to placeholders: $teHome and $content. A placeholder is just something that starts with $. Any whitespace or special character terminates a placeholder. If you want special characters inside your placeholder, use curly braces, for example ${special_content}.

Tazuna tries to replace the placeholders with content. The content is defined in content (.cnt) files. Content is defined by placing a placeholder at the beginning of a line and than writing the content of the placeholder.

File: index.cnt

<h1>Simple Page</h1>

This is a very simple page.

That was easy wasn't it? But wait. What's with $teHome? It is not defined in the content file. Well, Tazuna has some build in placeholders to make life easier. Build in placeholders start with the prefix te. te stands for, call it whatever you like: Template Engine, Tazuna Environment, Tina's Egg,... It's just a convention to avoid name conflicts.

$teHome provides a relative path to your server's home directory. If you want to link to any file on your server, use a full path and put a $teHome in front of it. That way your files will also work in a filesystem. So you don't need a webserver to test your pages.

Adding a Script to the Content

There is a directory called private_scripts. Files and directory starting with private_ are not copied into the out directory. For this example private_scripts contains just one Python script called hello.py. Let's see what it does.

Open the file index.cnt and and add a $hello placeholder.

File: index.cnt

<h1>Simple Page</h1>

This is a very simple page. $hello

Run Tazuna again and you will see that $hello has been replaced by Hello World! in the output file index.html.

If Tazuna finds a placeholder, that is not defined in a content file, it looks for a script of the same name.

In this case the script is rather simple:

File: hello.py

# -*- coding: utf-8 -*-

result = u'Hello World!'

Tazuna will replace the placeholder $hello with the value of the result variable. The result variable must be a Unicode string. See http://www.python.org for more about the Python programming language.

Previous: Installation ----- Contents: Contents ----- Next: Creole Markup
Built with Tazuna.