PHP 클래스 Think\Template\TagLib\Cx

저자: liu21st ([email protected])
상속: extends Taglib
파일 보기 프로젝트 열기: top-think/framework 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$tags 标签定义

공개 메소드들

메소드 설명
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}

메소드 상세

tagAssign() 공개 메소드

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

tagCase() 공개 메소드

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

tagCompare() 공개 메소드

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 标签内容
리턴 string

tagDefault() 공개 메소드

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

tagDefine() 공개 메소드

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

tagDefined() 공개 메소드

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

tagElse() 공개 메소드

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

tagElseif() 공개 메소드

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

tagEmpty() 공개 메소드

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

tagFor() 공개 메소드

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

tagForeach() 공개 메소드

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 标签内容
리턴 string | void

tagFunction() 공개 메소드

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 标签内容
리턴 string

tagIf() 공개 메소드

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 标签内容
리턴 string

tagLoad() 공개 메소드

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

tagNotdefined() 공개 메소드

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

tagNotempty() 공개 메소드

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

tagNotpresent() 공개 메소드

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

tagPhp() 공개 메소드

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

tagPresent() 공개 메소드

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

tagRange() 공개 메소드

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 标签内容
리턴 string

tagSwitch() 공개 메소드

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 标签内容
리턴 string

tagUrl() 공개 메소드

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

tagVolist() 공개 메소드

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

프로퍼티 상세

$tags 보호되어 있는 프로퍼티

标签定义
protected $tags