PHP Class Think\Template\TagLib\Cx

Author: liu21st ([email protected])
Inheritance: extends Taglib
Afficher le fichier Open project: top-think/framework Class Usage Examples

Protected Properties

Свойство Type Description
$tags 标签定义

Méthodes publiques

Méthode Description
tagAssign ( array $tag, string $content ) : string assign标签解析 在模板中给某个变量赋值 支持变量赋值 格式: {assign name="" value="" /}
tagCase ( array $tag, string $content ) : string case标签解析 需要配合switch才有效
tagCompare ( array $tag, string $content ) : string compare标签解析 用于值的比较 支持 eq neq gt lt egt elt heq nheq 默认是eq 格式: {compare name="" type="eq" value="" }content{/compare}
tagDefault ( array $tag ) : string default标签解析 需要配合switch才有效 使用: {default /}ddfdf
tagDefine ( array $tag, string $content ) : string define标签解析 在模板中定义常量 支持变量赋值 格式: {define name="" value="" /}
tagDefined ( array $tag, string $content ) : string 判断是否已经定义了该常量 {defined name='TXT'}已定义{/defined}
tagElse ( array $tag ) : string else标签解析 格式:见if标签
tagElseif ( array $tag, string $content ) : string elseif标签解析 格式:见if标签
tagEmpty ( array $tag, string $content ) : string empty标签解析 如果某个变量为empty 则输出内容 格式: {empty name="" }content{/empty}
tagFor ( array $tag, string $content ) : string for标签解析 格式: {for start="" end="" comparison="" step="" name=""} content {/for}
tagForeach ( array $tag, string $content ) : string | void foreach标签解析 循环输出数据集 格式: {foreach name="userList" id="user" key="key" index="i" mod="2" offset="3" length="5" empty=""} {user.username} {/foreach}
tagFunction ( array $tag, string $content ) : string function标签解析 匿名函数,可实现递归 使用: {function name="func" vars="$data" call="$list" use="&$a,&$b"} {if is_array($data)} {foreach $data as $val} {~func($val) /} {/foreach} {else /} {$data} {/if} {/function}
tagIf ( array $tag, string $content ) : string if标签解析 格式: {if condition=" $a eq 1"} {elseif condition="$a eq 2" /} {else /} {/if} 表达式支持 eq neq gt egt lt elt == > >= < <= or and || &&
tagLoad ( array $tag, string $content ) : string load 标签解析 {load file="/static/js/base.js" /} 格式:{load file="/static/css/base.css" /}
tagNotdefined ( array $tag, string $content ) : string 判断是否没有定义了该常量 {notdefined name='TXT'}已定义{/notdefined}
tagNotempty ( array $tag, string $content ) : string notempty标签解析 如果某个变量不为empty 则输出内容 格式: {notempty name="" }content{/notempty}
tagNotpresent ( array $tag, string $content ) : string notpresent标签解析 如果某个变量没有设置,则输出内容 格式: {notpresent name="" }content{/notpresent}
tagPhp ( array $tag, string $content ) : string php标签解析 格式: {php}echo $name{/php}
tagPresent ( array $tag, string $content ) : string present标签解析 如果某个变量已经设置 则输出内容 格式: {present name="" }content{/present}
tagRange ( array $tag, string $content ) : string range标签解析 如果某个变量存在于某个范围 则输出内容 type= in 表示在范围内 否则表示在范围外 格式: {range name="var|function" value="val" type='in|notin' }content{/range} example: {range name="a" value="1,2,3" type='in' }content{/range}
tagSwitch ( array $tag, string $content ) : string switch标签解析 格式: {switch name="a.name"} {case value="1" break="false"}1{/case} {case value="2" }2{/case} {default /}other {/switch}
tagUrl ( array $tag, string $content ) : string U函数的tag标签 格式:{url link="模块/控制器/方法" vars="参数" suffix="true或者false 是否带有后缀" domain="true或者false 是否携带域名" /}
tagVolist ( array $tag, string $content ) : string | void volist标签解析 循环输出数据集 格式: {volist name="userList" id="user" empty=""} {user.username} {user.email} {/volist}

Method Details

tagAssign() public méthode

assign标签解析 在模板中给某个变量赋值 支持变量赋值 格式: {assign name="" value="" /}
public tagAssign ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagCase() public méthode

case标签解析 需要配合switch才有效
public tagCase ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagCompare() public méthode

compare标签解析 用于值的比较 支持 eq neq gt lt egt elt heq nheq 默认是eq 格式: {compare name="" type="eq" value="" }content{/compare}
public tagCompare ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagDefault() public méthode

default标签解析 需要配合switch才有效 使用: {default /}ddfdf
public tagDefault ( array $tag ) : string
$tag array 标签属性
Résultat string

tagDefine() public méthode

define标签解析 在模板中定义常量 支持变量赋值 格式: {define name="" value="" /}
public tagDefine ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagDefined() public méthode

判断是否已经定义了该常量 {defined name='TXT'}已定义{/defined}
public tagDefined ( array $tag, string $content ) : string
$tag array
$content string
Résultat string

tagElse() public méthode

else标签解析 格式:见if标签
public tagElse ( array $tag ) : string
$tag array 标签属性
Résultat string

tagElseif() public méthode

elseif标签解析 格式:见if标签
public tagElseif ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagEmpty() public méthode

empty标签解析 如果某个变量为empty 则输出内容 格式: {empty name="" }content{/empty}
public tagEmpty ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagFor() public méthode

for标签解析 格式: {for start="" end="" comparison="" step="" name=""} content {/for}
public tagFor ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagForeach() public méthode

foreach标签解析 循环输出数据集 格式: {foreach name="userList" id="user" key="key" index="i" mod="2" offset="3" length="5" empty=""} {user.username} {/foreach}
public tagForeach ( array $tag, string $content ) : string | void
$tag array 标签属性
$content string 标签内容
Résultat string | void

tagFunction() public méthode

function标签解析 匿名函数,可实现递归 使用: {function name="func" vars="$data" call="$list" use="&$a,&$b"} {if is_array($data)} {foreach $data as $val} {~func($val) /} {/foreach} {else /} {$data} {/if} {/function}
public tagFunction ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagIf() public méthode

if标签解析 格式: {if condition=" $a eq 1"} {elseif condition="$a eq 2" /} {else /} {/if} 表达式支持 eq neq gt egt lt elt == > >= < <= or and || &&
public tagIf ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagLoad() public méthode

load 标签解析 {load file="/static/js/base.js" /} 格式:{load file="/static/css/base.css" /}
public tagLoad ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagNotdefined() public méthode

判断是否没有定义了该常量 {notdefined name='TXT'}已定义{/notdefined}
public tagNotdefined ( array $tag, string $content ) : string
$tag array
$content string
Résultat string

tagNotempty() public méthode

notempty标签解析 如果某个变量不为empty 则输出内容 格式: {notempty name="" }content{/notempty}
public tagNotempty ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagNotpresent() public méthode

notpresent标签解析 如果某个变量没有设置,则输出内容 格式: {notpresent name="" }content{/notpresent}
public tagNotpresent ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagPhp() public méthode

php标签解析 格式: {php}echo $name{/php}
public tagPhp ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagPresent() public méthode

present标签解析 如果某个变量已经设置 则输出内容 格式: {present name="" }content{/present}
public tagPresent ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagRange() public méthode

range标签解析 如果某个变量存在于某个范围 则输出内容 type= in 表示在范围内 否则表示在范围外 格式: {range name="var|function" value="val" type='in|notin' }content{/range} example: {range name="a" value="1,2,3" type='in' }content{/range}
public tagRange ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagSwitch() public méthode

switch标签解析 格式: {switch name="a.name"} {case value="1" break="false"}1{/case} {case value="2" }2{/case} {default /}other {/switch}
public tagSwitch ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagUrl() public méthode

U函数的tag标签 格式:{url link="模块/控制器/方法" vars="参数" suffix="true或者false 是否带有后缀" domain="true或者false 是否携带域名" /}
public tagUrl ( array $tag, string $content ) : string
$tag array 标签属性
$content string 标签内容
Résultat string

tagVolist() public méthode

volist标签解析 循环输出数据集 格式: {volist name="userList" id="user" empty=""} {user.username} {user.email} {/volist}
public tagVolist ( array $tag, string $content ) : string | void
$tag array 标签属性
$content string 标签内容
Résultat string | void

Property Details

$tags protected_oe property

标签定义
protected $tags