PHP 클래스 Contao\Template

The class supports loading template files, adding variables to them and then printing them to the screen. It functions as abstract parent class for the two core classes "BackendTemplate" and "FrontendTemplate". Usage: $template = new BackendTemplate(); $template->name = 'Leo Feyer'; $template->output();
상속: extends Controller, use trait TemplateInheritance
파일 보기 프로젝트 열기: contao/core-bundle 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$arrData array Template data
$strBuffer string Output buffer
$strContentType string Content type
$validJavaScriptTypes array Valid JavaScipt types

공개 메소드들

메소드 설명
__call ( string $strKey, array $arrParams ) : mixed Execute a callable and return the result
__construct ( string $strTemplate = '', string $strContentType = 'text/html' ) Create a new template object
__get ( string $strKey ) : mixed Return an object property
__isset ( string $strKey ) : boolean Check whether a property is set
__set ( string $strKey, mixed $varValue ) Set an object property
dumpTemplateVars ( ) Print all template variables to the screen using var_dump
flushAllData ( ) Flush the output buffers
generateFeedTag ( string $href, string $format, string $title ) : string Generate the markup for an RSS feed tag
generateInlineScript ( string $script ) : string Generate the markup for an inline JavaScript
generateInlineStyle ( string $script ) : string Generate the markup for inline CSS code
generateScriptTag ( string $src, boolean $async = false ) : string Generate the markup for a JavaScript tag
generateStyleTag ( string $href, string $media = null ) : string Generate the markup for a style sheet tag
getData ( ) : array Return the template data as array
getFormat ( ) : string Return the output format
getName ( ) : string Return the template name
getResponse ( ) : Response Return a response object
minifyHtml ( string $strHtml ) : string Minify the HTML markup preserving pre, script, style and textarea tags
output ( ) Parse the template file and print it to the screen
parse ( ) : string Parse the template file and return it as string
route ( string $strName, array $arrParams = [] ) : string Return a route relative to the base URL
setData ( array $arrData ) Set the template data from an array
setFormat ( string $strFormat ) Set the output format
setName ( string $strTemplate ) Set the template name
showTemplateVars ( ) Print all template variables to the screen using print_r

보호된 메소드들

메소드 설명
compile ( ) Compile the template
getDebugBar ( ) : string Return the debug bar string

메소드 상세

__call() 공개 메소드

Execute a callable and return the result
public __call ( string $strKey, array $arrParams ) : mixed
$strKey string The name of the key
$arrParams array The parameters array
리턴 mixed The callable return value

__construct() 공개 메소드

Create a new template object
public __construct ( string $strTemplate = '', string $strContentType = 'text/html' )
$strTemplate string The template name
$strContentType string The content type (defaults to "text/html")

__get() 공개 메소드

Return an object property
public __get ( string $strKey ) : mixed
$strKey string The property name
리턴 mixed The property value

__isset() 공개 메소드

Check whether a property is set
public __isset ( string $strKey ) : boolean
$strKey string The property name
리턴 boolean True if the property is set

__set() 공개 메소드

Set an object property
public __set ( string $strKey, mixed $varValue )
$strKey string The property name
$varValue mixed The property value

compile() 보호된 메소드

Compile the template
protected compile ( )

dumpTemplateVars() 공개 메소드

Print all template variables to the screen using var_dump
public dumpTemplateVars ( )

flushAllData() 공개 메소드

Flush the output buffers
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0.
public flushAllData ( )

generateFeedTag() 공개 정적인 메소드

Generate the markup for an RSS feed tag
public static generateFeedTag ( string $href, string $format, string $title ) : string
$href string The script path
$format string The feed format
$title string The feed title
리턴 string The markup string

generateInlineScript() 공개 정적인 메소드

Generate the markup for an inline JavaScript
public static generateInlineScript ( string $script ) : string
$script string The JavaScript code
리턴 string The markup string

generateInlineStyle() 공개 정적인 메소드

Generate the markup for inline CSS code
public static generateInlineStyle ( string $script ) : string
$script string The CSS code
리턴 string The markup string

generateScriptTag() 공개 정적인 메소드

Generate the markup for a JavaScript tag
public static generateScriptTag ( string $src, boolean $async = false ) : string
$src string The script path
$async boolean True to add the async attribute
리턴 string The markup string

generateStyleTag() 공개 정적인 메소드

Generate the markup for a style sheet tag
public static generateStyleTag ( string $href, string $media = null ) : string
$href string The script path
$media string The media type string
리턴 string The markup string

getData() 공개 메소드

Return the template data as array
public getData ( ) : array
리턴 array The data array

getDebugBar() 보호된 메소드

Return the debug bar string
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0.
protected getDebugBar ( ) : string
리턴 string The debug bar markup

getFormat() 공개 메소드

Return the output format
public getFormat ( ) : string
리턴 string The output format

getName() 공개 메소드

Return the template name
public getName ( ) : string
리턴 string The template name

getResponse() 공개 메소드

Return a response object
public getResponse ( ) : Response
리턴 Symfony\Component\HttpFoundation\Response The response object

minifyHtml() 공개 메소드

Minify the HTML markup preserving pre, script, style and textarea tags
public minifyHtml ( string $strHtml ) : string
$strHtml string The HTML markup
리턴 string The minified HTML markup

output() 공개 메소드

Parse the template file and print it to the screen
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Template::getResponse() instead.
public output ( )

parse() 공개 메소드

Parse the template file and return it as string
public parse ( ) : string
리턴 string The template markup

route() 공개 메소드

Return a route relative to the base URL
public route ( string $strName, array $arrParams = [] ) : string
$strName string The route name
$arrParams array The route parameters
리턴 string The route

setData() 공개 메소드

Set the template data from an array
public setData ( array $arrData )
$arrData array The data array

setFormat() 공개 메소드

Set the output format
public setFormat ( string $strFormat )
$strFormat string The output format

setName() 공개 메소드

Set the template name
public setName ( string $strTemplate )
$strTemplate string The template name

showTemplateVars() 공개 메소드

Print all template variables to the screen using print_r
public showTemplateVars ( )

프로퍼티 상세

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

Template data
protected array $arrData
리턴 array

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

Output buffer
protected string $strBuffer
리턴 string

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

Content type
protected string $strContentType
리턴 string

$validJavaScriptTypes 보호되어 있는 정적으로 프로퍼티

Valid JavaScipt types
또한 보기: http://www.w3.org/TR/html5/scripting-1.html#scriptingLanguages
protected static array $validJavaScriptTypes
리턴 array