Syntax rules used in templates:
Example: templates/default/content/show.html
1. Variable representation
{$title} is parsed into <?php echo $title;? >
Final value: I am the title
2. Constant representation
{R} is parsed into <?php echo R;? >
Final value:/HTTP//My domain/res/
For example:
<link href= "{r}t3/css/bootstrap.css" rel= "stylesheet" ><link href= "{r}t3/css/style.css" rel= "stylesheet" ><link href= "{r}t3/css/hover.css" rel= "stylesheet" >
3. Condition Judgment
{if condition} content to display 1 {else} content to display 2 {else} content to display 3{/if}
or {if condition} to display the contents {/if}
For example:
{if $title! = '} {$title} {/if}
4. Circulation
{Loop $a $b} * {/loop}
is parsed into:
<?phpforeach ($a as $b) {}?>
At the same time, $n variables are added automatically, such as:
<?php$n=1;foreach ($a as $b) {$n + +;}? >
Instance:
{Loop $rs $r} rank: {$n}, Title: {$r [' title ']}{/loop}
{Loop $res $key $value} primary key: {$key}, value {$value}{/loop}
resolves to:
<?phpforeach ($res as $key = $value) {?> primary key: <?php echo $key;? , Value <?php echo $value;? ><?php}?>
5. The template contains
{T ' module directory name ', ' filename '}
For example:
{T "content", "Head", Tplid}
6. Self-increment, self-reduction
For example:
{php $i = 10;} {loop $a $b}<li>{$i}</li>{$i ++}{/loop}
Parameter: auto-subtract {$i--} {--$i} increment {$i + +} {+ + $i}
7. Single-line PHP parsing:
For example: {php $i = 1;} is resolved to: <?php echo $i = 1;? >
For example: {php $string = date (' y-m-d '),} resolves to: <?php $string = Date (' y-m-d ');? >
Wuzhicms template Syntax