yii-thplike thp is simple template preprocessor for valid make-up

  1. Requirements
  2. Install and configure
  3. Usage
  4. Resources

This is simple template preprocessor for valid make-up. It's use simple syntax for create valid templates.

Requirements ¶

Yii 1.1 or above Extention use CViewRenderer for compile templates.

Install and configure ¶

  • copy ThpViewRenderer.php to ext.wartur.thp
  • add to config
// ...
'import'=>array(
    //...
    'ext.wartur.yii-thplike.*',
    //...
),
// ...
'components' => array(
	//...
	'viewRenderer' => array(
		'class' => 'ThpViewRenderer',
	),
),

Usage ¶

If you already using PHP template syntax you may don't worry. This ViewRenderer
backward compatible with PHP syntax.
Enable component and enjoy it.

After compilation you can see your template at /protected/runtime/view

SYNTAX:
==================> PHP Syntax
<? if(false): ?>
<? endif; ?>

<? foreach($arr as $e): ?>
<? endforeach; ?>

and any more are working, for compatibility testing are use gii extension

==================> THP-like Syntax
THP-like syntax is PHP syntax with thp processing.
the main problem is that a document was obtained html valid
The following problems are solved:
1) dynamic block of code (such as if, foreach, and other) set as html comment
2) vars on layout set as text and minimalist.

<!--<? if(false): ?>-->
<!--<? endif; ?>-->

<!--<? foreach($arr as $e): ?>-->
<!--<? endforeach; ?>-->

and other
you can using yii construction and widget, without problem
<!--<? CForm:: .... ?>-->

==================> THP Syntax
this is minimalist syntax for template.
--- blocks layouts
<!--!! --> - all inside is cut from template

<!--// CUT -->
All between is cut form template 
<!--\\ CUT -->

<!--// IFSET|IFEMPTY|IFTRUE thpvar --> = if(isset(thpvar)|empty(thpvar)|thpvar)
<!--|| ELSE -->
<!--\\ IF(or IFSET|IFTRUE|IFEMPTY) --> = endif

<!--// LOOP thpvar --> = foreach($thpvar as $e)
{e.var} = {.var}
<!--\\ LOOP (may add thpvar) --> = endforeach

this construction already support thpvar conversion described below

--- vars layout (thpvar):
{thisvar} = <?=$thisvar;?>
{el.thisvar} = <?=$el['thisvar'];?>
{el->thisvar} = <?=$el->thisvar;?>
{el->thismethod()} = <?=$el->thismethod();?>

this is reduced notation
{.thisvar} = <?=$e['thisvar'];?>

you may do arbitrary combination of code
{.var->obj->obj.el.el} = <?=$e['var']->obj->obj['el']['el'];?>

Resources ¶

0 0
1 follower
140 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: wartur wartur
Created on: Sep 3, 2014
Last updated: 11 years ago

Downloads

show all

Related Extensions