Tempo – 2.Step by step

Learn howto step by step

The main steps are:

  1. Prepare Template contents
  2. Include the tempo class(tempo)
  3. Instantiate class
  4. Parse the template contents
  5. Set variable
  6. Assign the template contents
  7. Output the assigned contents
  8. Clear the parsed contents

1. Prepare Template contents

A template contents(file or string) is basically an HTML document that also contain variable substitutions (enclosed with the begin tag {?= and end tag ?}) and special HTML tag attributes “tempo:statemants.

2. Include the tempo class

You should first include the tempo class(class.tempo.php) by require_once() or include_once(). Here is how you create an instance of Tempo in your PHP scripts.

3. Instantiate class

Instantiate class using operator new.

4. Parse the template contents

Parse the template contents(file or string) by its method parse() or parse_str(). First parameter is the template handle corresponding the template contents to be processed.

5. Set variable

There is no method for setting variable. You are able to use global variables in PHP.

6. Assign the template contents

This inserts the values of all the variables that have been set into the template. First parameter of parse() method, template handle name is the created template object name.

7. Output the assigned contents

You are able to use the PHP built-in function print or etc to output the assigned contents.

8. Clear the parsed contents

This clear the parsed contents. Using method close() isn’t usually necessary, the parsed contents is automatically cleared at the end of the script’s execution.

답글 남기기