Provides various official and user-released code examples, code reference, you are welcome to exchange and learn. The template supports {if} {elseif} {else} {/if} {for} {/for} {loop} {/loop} type labels.
I was just using thinkphp for development. It was crazy to have built-in labels when embedding templates. Although it was very powerful, it was too cumbersome. So I added several new labels based on simple and practical principles, it is easy for you to use.
Usage:
Condition judgment
{If *} * {else} * {/if}
Or {if *} * {elseif *} * {else} * {/if}
Or {if *} * {/if}
* In {if *} is the condition expression of the judgment statement, which complies with the php expression.
Example:
{If! Empty ($ c) | $ a> 10 & $ B <10}
{$ C}
{Elseif $ a> 10}
{$}
{Else}
{$ B}
{/If}
Foreach Traversal
{Loop $ a $ B} * {/loop} or {loop $ a $ B $ c} * {/loop}
Example:
{Loop $ a $ B $ c}
Entry {$ n}: {$ B }=>{ $ c}
{/Loop}
For Loop
{for $i=0;$i<10;$i++}*{/for}
Auto-increment or auto-subtraction example
Auto increment {$ I --} {-- $ I} {$ I ++ $ I}
Single-line PHP parsing syntax
{Php $ I = 1;} is parsed:
{Php $ string = date ('Y-m-d');} resolved:
Add method:
This is a step-by-step manual for adding behavior extensions.
1. Place the file in the attachment in the Common \ Behavior folder of the project.
2. Behavior definition Configuration:
'template_filter'=>array('Common\\Behavior\\SimpleTemplate')
3.2.1 The code for changing the behavior definition configuration is as follows:
'template_filter'=>array('Common\\Behavior\\SimpleTemplateBehavior')
3. Add the Enable identifier to the project configuration file:
'STPL_SWITCH_ON'=>TRUE
This code is extracted from phpcms
SimpleTemplateBehavior.class.rar (765 B download: 85 times)
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB