WACT_TEMPLATE
[ class tree: WACT_TEMPLATE ] [ index: WACT_TEMPLATE ] [ all elements ]

Class: CodeWriter

Source Location: /framework/template/compiler/codewriter.inc.php

http://wact.sourceforge.net/index.php/CodeWriter

Class Overview


Provides an API for generating the compiled template.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

Provides an API for generating the compiled template.
abstract:  
access:  public
see:  http://wact.sourceforge.net/index.php/CodeWriter

Class Variables


$code =

String containing the compiled template
access:  private
Type:   string

$FunctionPrefix =

A prefix to add to the compiled template construct and render functions
access:  private
Type:   string

$FunctionSuffix = 1

A suffix to add to the compiled template construct and render functions
var:  (default 1)
access:  private
Type:   int

$includeList = array()

List of files to write include statements for in the compiled template, such as runtime component class files.
access:  private
Type:   array

$mode = CODE_WRITER_MODE_HTML

The current state of the writer.
var:  (default CODE_WRITER_MODE_HTML);
access:  private
Type:   int

$tempVarName = 1

Count of the current number of temporary variables in the template
var:  (default 1)
access:  private
Type:   int

Class Methods


constructor CodeWriter

Constructs CodeWriter, initializing the internal code string

CodeWriter CodeWriter( )

API Tags:

access:  public

method beginFunction

Begins writing a PHP function to the compiled template, using the FunctionPrefix and the FunctionSuffix, the latter being post incremented by one.

string beginFunction( string $ParamList)

API Tags:

return:  name of the function of form "tpl[Prefix:hash][Suffix:int]
access:  public

Parameters:

string   $ParamList   parameter string for the function declaration

method endFunction

Finish writing a PHP function to the compiled template

void endFunction( )

API Tags:

access:  public

method escapeLiteral

Escape a string in preperation for writing a PHP Literal String.

Make sure that escape characters are proper for source code escaping of string literal.



string escapeLiteral( string $text)

API Tags:

access:  public

Parameters:

string   $text   text to escape

method getCode

Returns the finished compiled template, adding the include directives at the start of the template

string getCode( )

API Tags:

access:  public

method getTempVariable

Utility method, which generates a unique variable name for custom use within TagComponents.

string getTempVariable( )

API Tags:

access:  public

method getTempVarRef

Utility method, which generates a unique variable name, prefixed with a $ for custom use within TagComponents.

string getTempVarRef( )

API Tags:

access:  public

method registerInclude

Adds an include file (e.g a runtime component class file) to the internal list.

Checks that file has not already been included.
Note that the path to the file to be included will need to be in PHP's runtime include path.



void registerInclude( string $includefile)

API Tags:

access:  public

Parameters:

string   $includefile   PHP script path/name

method setFunctionPrefix

Sets the function prefix

void setFunctionPrefix( string $prefix)

API Tags:

access:  public

Parameters:

string   $prefix   prefix for function names to be written

method switchToHTML

Puts the writer into HTML mode, writing an closing PHP processing instruction to the template.

Does nothing if writer is already in HTML mode



void switchToHTML( [mixed $Context = NULL])

API Tags:

access:  private

method switchToPHP

Puts the writer into PHP mode, writing an opening PHP processing instruction to the template.

Does nothing if writer is already in PHP mode



void switchToPHP( )

API Tags:

access:  private

method writeHTML

Writes some HTML to the compiled template

void writeHTML( string $text)

API Tags:

access:  public

Parameters:

string   $text   HTML to write

method writePHP

Writes some PHP to the compiled template

void writePHP( string $text)

API Tags:

access:  public

Parameters:

string   $text   PHP to write

method writePHPLiteral

Write PHP Literal String.

Make sure that escape characters are proper for source code escaping of string literal.



void writePHPLiteral( string $text, [boolean $escape = true])

API Tags:

access:  public

Parameters:

string   $text   PHP to write
boolean   $escape   optional - text requires escape, defaults to true
WACT: Copyright 2003 Procata, Inc. Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html)
Documentation generated on Sun, 28 Nov 2004 19:44:29 -0800 by phpDocumentor 1.2.3