Coeus Framework  1.0
Public Member Functions | Data Fields
template Class Reference

DOM based template engine. More...

Public Member Functions

 __construct ( $masterTemplate=HTML_PATH . TEMPLATE_DEFAULT_MASTER)
 
 add ( $tagId, $template)
 Add a sub-template. More...
 
 insertJs ( $jsCode)
 Inserts javascript code into the master and appends it to the <head> section of HTML. This is useful to send data to JavaScript on page load from PHP. More...
 

Data Fields

 $DOM
 DOM Object.
 

Detailed Description

DOM based template engine.

Author
David A. Lamkin dlamk.nosp@m.in@c.nosp@m.oupon.nosp@m.wall.nosp@m.et.co.nosp@m.m
Version
1.0
Process flow:
  • Loads the master template into memory
  • Then loads the framework files (in order) and puts them into the <head>
  • You add your child template(s)
  • Add any JavaScript code
  • On __destruct, it renders and prints the HTML
Usage Example:
$tpl = new template;
$tpl->add('main", 'myPage.html');
$tpl->insertJs('console.log(' . $jsonData . ');');
Todo:
Add changing of the TITLE tag via php

Member Function Documentation

◆ add()

add (   $tagId,
  $template 
)

Add a sub-template.

Parameters
string$tagIdThe name of the <template> tag to replace
string$templateThe name of the template file
Returns
$this
Usage Example:
First, in HTML
<body>
<template name="main"></template>
</body>
Then in PHP
$tpl->add('main", 'myPage.html');

◆ insertJs()

insertJs (   $jsCode)

Inserts javascript code into the master and appends it to the <head> section of HTML. This is useful to send data to JavaScript on page load from PHP.

Parameters
$jsCodestring JavaScript code
Usage Example:
$tpl->insertJs('console.log("Hello world!");');
Outputs:
<script class="injectedJs">console.log("Hello world!");</script>

The documentation for this class was generated from the following file: