Class LatteMacros
Default macros for filter LatteFilter.
- {$variable} with escaping
- {!$variable} without escaping
- {comment} will be removed
- {=expression} echo with escaping
- {!=expression} echo without escaping
- {?expression} evaluate PHP statement
- {_expression} echo translation with escaping
- {!_expression} echo translation without escaping
- {link destination …} control link
- {plink destination …} presenter link
- {if ?} … {elseif ?} … {else} … {/if}
- {ifset ?} … {elseifset ?} … {/if}
- {for ?} … {/for}
- {foreach ?} … {/foreach}
- {include ?}
- {cache ?} … {/cache} cached block
- {snippet ?} … {/snippet ?} control snippet
- {attr ?} HTML element attributes
- {block|texy} … {/block} block
- {contentType …} HTTP Content-Type header
- {status …} HTTP status
- {capture ?} … {/capture} capture block to parameter
- {var var ⇒ value} set template parameter
- {default var ⇒ value} set default template parameter
- {dump $var}
- {debugbreak}
- {l} {r} to display { }
- Object
-
LatteMacros
public
|
#
__construct(
)
Constructor. Constructor. |
public
void
|
#
initialize(
LatteFilter
$filter,
string
& $s
)
Initializes parsing. Initializes parsing. Parameters$filter LatteFilter$s string |
public
void
|
#
finalize(
string
& $s
)
Finishes parsing. Finishes parsing. Parameters$s string |
public
string
|
#
macro(
string
$macro,
string
$content,
string
$modifiers
)
Process {macro content | modifiers} Process {macro content | modifiers} Parameters$macro string$content string$modifiers string |
public
string
|
#
tagMacro(
string
$name,
array
$attrs,
bool
$closing
)
Process <n:tag attr> (experimental). Process <n:tag attr> (experimental). Parameters$name string$attrs array$closing bool |
public
string
|
#
attrsMacro(
string
$code,
array
$attrs,
bool
$closing
)
Process <tag n:attr> (experimental). Process <tag n:attr> (experimental). Parameters$code string$attrs array$closing bool |
public
|
#
macroDollar(
$var,
$modifiers
)
{$var |modifiers} {$var |modifiers} |
public
|
#
macroTranslate(
$var,
$modifiers
)
{_$var |modifiers} {_$var |modifiers} |
public
|
#
macroSyntax(
$var
)
{syntax …} {syntax …} |
public
|
#
macroInclude(
$content,
$modifiers,
$isDefinition = false
)
{include …} {include …} |
public
|
#
macroExtends(
$content
)
{extends …} {extends …} |
public
|
#
macroBlock(
$content,
$modifiers
)
{block …} {block …} |
public
|
#
macroBlockEnd(
$content
)
{/block} {/block} |
public
|
#
macroSnippet(
$content
)
{snippet …} {snippet …} |
public
|
#
macroSnippetEnd(
$content
)
{snippet …} {snippet …} |
public
|
#
macroCapture(
$content,
$modifiers
)
{capture …} {capture …} |
public
|
#
macroCaptureEnd(
$content
)
{/capture} {/capture} |
public
|
#
macroCache(
$content
)
{cache …} {cache …} |
public
|
#
macroForeach(
$content
)
{foreach …} {foreach …} |
public
|
#
macroAttr(
$content
)
{attr …} {attr …} |
public
|
#
macroContentType(
$content
)
{contentType …} {contentType …} |
public
|
#
macroDump(
$content
)
{dump …} {dump …} |
public
|
#
macroDebugbreak(
)
{debugbreak} {debugbreak} |
public
|
#
macroControl(
$content
)
{control …} {control …} |
public
|
#
macroLink(
$content,
$modifiers
)
{link …} {link …} |
public
|
#
macroPlink(
$content,
$modifiers
)
{plink …} {plink …} |
public
|
#
macroIfCurrent(
$content
)
{ifCurrent …} {ifCurrent …} |
public
|
#
macroVar(
$content,
$modifiers,
$extract = false
)
{var …} {var …} |
public
|
#
macroDefault(
$content
)
{default …} {default …} |
public
|
#
macroEscape(
$content
)
Escaping helper. Escaping helper. |
public
|
#
macroModifiers(
$content,
$modifiers
)
Just modifiers helper. Just modifiers helper. |
public static
string
|
#
formatModifiers(
string
$var,
string
$modifiers
)
Applies modifiers. Applies modifiers. Parameters$var string$modifiers string |
public static
string
|
#
fetchToken(
string
& $s
)
Reads single token (optionally delimited by comma) from string. Reads single token (optionally delimited by comma) from string. Parameters$s string |
public static
string
|
#
formatArray(
string
$input,
string
$prefix = ''
)
Formats parameters to PHP array. Formats parameters to PHP array. Parameters$input string$prefix string |
public static
string
|
#
formatString(
string
$s
)
Formats parameter to PHP string. Formats parameter to PHP string. Parameters$s string |
public static
void
|
#
callBlock(
stdClass
$context,
string
$name,
array
$params
)
Calls block. Calls block. Parameters$context stdClass$name string$params array |
public static
void
|
#
callBlockParent(
stdClass
$context,
string
$name,
array
$params
)
Calls parent block. Calls parent block. Parameters$context stdClass$name string$params array |
public static
Template
|
#
includeTemplate(
mixed
$destination,
array
$params,
ITemplate
$template
)
Includes subtemplate. Includes subtemplate. Parameters$destination mixed included file name or template$params array parameters$template ITemplate current template |
public static
stdClass
|
#
initRuntime(
ITemplate
$template,
bool
$extends,
string
$realFile
)
Initializes local & global storage in template. Initializes local & global storage in template. Parameters$template ITemplate$extends bool$realFile string |
public static
|
#
renderSnippets(
$control,
$local,
$params
)
|
Methods Inherited From Object
getReflection(), __call(), __callStatic(), extensionMethod(), __get(), __set(), __isset(), __unset()
RE_IDENTIFIER |
'[_a-zA-Z\\x7F-\\xFF][_a-zA-Z0-9\\x7F-\\xFF]*' # |
T_SYMBOL |
-1 # |
BLOCK_NAMED |
1 # |
BLOCK_CAPTURE |
2 # |
BLOCK_ANONYMOUS |
3 # |
static
array
|
$defaultMacros | array ( 'syntax' => '%:macroSyntax%', '/syntax' => '%:macroSyntax%', 'block' => '<?php %:macroBlock% ?>', '/block' => '<?php %:macroBlockEnd% ?>', 'capture' => '<?php %:macroCapture% ?>', '/capture' => '<?php %:macroCaptureEnd% ?>', 'snippet' => '<?php %:macroSnippet% ?>', '/snippet' => '<?php %:macroSnippetEnd% ?>', 'cache' => '<?php %:macroCache% ?>', '/cache' => '<?php array_pop($_l->g->caches)->save(); } ?>', 'if' => '<?php if (%%): ?>', 'elseif' => '<?php elseif (%%): ?>', 'else' => '<?php else: ?>', '/if' => '<?php endif ?>', 'ifset' => '<?php if (isset(%%)): ?>', '/ifset' => '<?php endif ?>', 'elseifset' => '<?php elseif (isset(%%)): ?>', 'foreach' => '<?php foreach (%:macroForeach%): ?>', '/foreach' => '<?php endforeach; array_pop($_l->its); $iterator = end($_l->its) ?>', 'for' => '<?php for (%%): ?>', '/for' => '<?php endfor ?>', 'while' => '<?php while (%%): ?>', '/while' => '<?php endwhile ?>', 'continueIf' => '<?php if (%%) continue ?>', 'breakIf' => '<?php if (%%) break ?>', 'first' => '<?php if ($iterator->isFirst(%%)): ?>', '/first' => '<?php endif ?>', 'last' => '<?php if ($iterator->isLast(%%)): ?>', '/last' => '<?php endif ?>', 'sep' => '<?php if (!$iterator->isLast(%%)): ?>', '/sep' => '<?php endif ?>', 'include' => '<?php %:macroInclude% ?>', 'extends' => '<?php %:macroExtends% ?>', 'layout' => '<?php %:macroExtends% ?>', 'plink' => '<?php echo %:macroEscape%(%:macroPlink%) ?>', 'link' => '<?php echo %:macroEscape%(%:macroLink%) ?>', 'ifCurrent' => '<?php %:macroIfCurrent% ?>', 'widget' => '<?php %:macroControl% ?>', 'control' => '<?php %:macroControl% ?>', 'attr' => '<?php echo Html::el(NULL)->%:macroAttr%attributes() ?>', 'contentType' => '<?php %:macroContentType% ?>', 'status' => '<?php Environment::getHttpResponse()->setCode(%%) ?>', 'var' => '<?php %:macroVar% ?>', 'assign' => '<?php %:macroVar% ?>', 'default' => '<?php %:macroDefault% ?>', 'dump' => '<?php %:macroDump% ?>', 'debugbreak' => '<?php %:macroDebugbreak% ?>', 'l' => '{', 'r' => '}', '!_' => '<?php echo %:macroTranslate% ?>', '_' => '<?php echo %:macroEscape%(%:macroTranslate%) ?>', '!=' => '<?php echo %:macroModifiers% ?>', '=' => '<?php echo %:macroEscape%(%:macroModifiers%) ?>', '!$' => '<?php echo %:macroDollar% ?>', '$' => '<?php echo %:macroEscape%(%:macroDollar%) ?>', '?' => '<?php %:macroModifiers% ?>', ) |
# |
array
|
$macros | NULL |
# |