Class Crafty_Compiler

Description

Crafty_Compiler class implementation

This is the compiler class of the Crafty template engine. If you just want to write templates, you will not need to make use of it. The Crafty class will spawn an instance for internal usage if required.

Located in /crafty/Crafty_Compiler.class.php (line 54)


	
			
Variable Summary
Method Summary
Crafty_Compiler __construct (Crafty $crafty)
void add_preparse (string $character)
mixed booleanize (string $value)
boolean compile ($template_hash $template_hash)
int line_number (string $content, int $offset, [string $start_line = 1])
boolean load ($template $template_o)
Variables
array $blocks = array() (line 64)

Stores all Crafty_Block instances

All blocks loaded will be created and stored in this array. They are indexed by their name.

  • access: public
Crafty_Config $config (line 85)

Stores the root Crafty_Config object

This object is loaded by the constructor from the Crafty_Compiler.config.xml file

  • access: public
array $cores = array() (line 75)

Stores all Crafty_Core_* instances

All Crafty_Core_* instances that are loaded, except for Crafty_Core_Define and Crafty_Core_Require, will be stored in this array indexed by their classname.

  • access: public
Crafty $crafty (line 105)

Object handle of a Crafty object

This is the object that created the current Crafty_Compiler class. Set by the Constructor

  • access: public
array $defines = array() (line 175)

Stores defined values

Associative array of all defines, created by load() using Crafty_Core_Define

  • access: public
array $preparse_final = array() (line 165)

Final replacements for $preparse_search

Those will be replaced just after parsing. Security will be cared of afterwards.

  • access: public
array $preparse_replace = array() (line 155)

Temporary replacements during the parsing process for $preparse_search

The constructor will create this array by some sha1 hashes

  • access: public
array $preparse_search = array() (line 146)

Array of strings that need to be replaced before parsing

Double backslashes, backslash and single quote, backslash and double quote are replaced during the process of parsing to protect the core pregs from beeing confused.

  • access: public
string $template_hash = '' (line 125)

Stores the name of the compiled template and its directory

This is the MD5 hash of realpath($template_name), constructed by Crafty::display()

  • access: public
string $template_path = '' (line 135)

Path to the uncompiled template

Set by load() and used by several Crafty_Core objects, e.g. to check if an external block is present.

  • access: public
boolean $variable_blocks_used = FALSE (line 115)

Are variable blocks used?

If this is TRUE compile() will also compile every loaded block as variable block into a separate file.

  • access: public
resource $write_c_file_handle (line 95)

Stores a filehandle to the compiled (binary) template

Crafty_Block::compileElement() will use this filehandle to write the compiled content into the file.

  • access: public
Methods
Constructor __construct (line 189)

Initializes a Crafty_Compiler instance

The constructor intializes a Crafty_Compiler instance and loads the required framework files, such as the class definitions for Crafty_Config, Crafty_Block, Crafty_Core, Crafty_Core_Define, Crafty_Core_Require and all other Crafty_Core_* classes.
It also instantiates the Crafty_Core_* classes and stores them in $cores

  • access: public
Crafty_Compiler __construct (Crafty $crafty)
  • Crafty $crafty: Crafty object that created this Compiler
add_preparse (line 545)

Adds a character(sequence) that will be able to be escaped by a backslash

  • access: public
void add_preparse (string $character)
  • string $character: character(sequence) to be escapable
booleanize (line 515)

Booleanize a value

Check the string for true|yes|on|1 / false|no|off|0 and return a boolean in that case

  • access: public
mixed booleanize (string $value)
  • string $value
compile (line 384)

Compiles a template

This method basically opens a compiled template file, adds the php tags and compiles the "main" block.
If variable blocks are used it also compiles any loaded template file into a separate file.

  • return: State of success
  • access: public
boolean compile ($template_hash $template_hash)
  • $template_hash $template_hash: Hashfilename of the current template
line_number (line 535)

Gets the linenumber of an offset

  • access: public
int line_number (string $content, int $offset, [string $start_line = 1])
  • string $content
  • int $offset
  • string $start_line: Optional: Default 1
load (line 252)

Loads a template file.

This method loads a template file, parses the $defines using Crafty_Core_Define, parses the requires using Crafty_Core_Require and calling itself for each require.
Then it parses the blocks and stores them in the $blocks array.

  • return: State of success
  • access: public
boolean load ($template $template_o)
  • $template $template_o: Relative path to the template

Documentation generated on Sat, 19 Feb 2005 01:43:40 +0100 by phpDocumentor 1.3.0RC3