public static
|
#
markup_template( array $args, Patron\Engine $patron, mixed $template )
Adds a template.
<p:template
name = qname>
<!-- Content: p:with-param*, template -->
</p:template>
The name attribute defines the name of the template. The content
of the markup defines the template.
Parameters
- $args
array $args
- $patron
Patron\Engine
$patron
- $template
mixed $template
|
public static
string
|
#
markup_call_template( array $args, Patron\Engine $patron, mixed $template )
Calls a template.
<p:call-template
name = qname>
<!-- Content: p:with-param* -->
</p:call-template>
Parameters
- $args
array $args
- $patron
Patron\Engine
$patron
- $template
mixed $template
Returns
string
|
public static
string
|
#
markup_foreach( array $args, Patron\Engine $patron, mixed $template )
Applies a template to each entries of the provided array.
Applies a template to each entries of the provided array.
<p:foreach
in = expression | this
as = qname | this>
<!-- Content: p:with-param*, template -->
</p:foreach>
At each turn the following variables are updated in self :
count : The number of entries.
position : The position of the current entry.
left : The number of entries left.
even : "even" if the position is even, an empty string
otherwise.
key : The key of the entry.
Parameters
- $args
array $args
- $patron
Patron\Engine
$patron
- $template
mixed $template
Returns
string
|
public static
|
#
markup_if( array $args, Patron\Engine $patron, mixed $template )
Provides a simple if-then conditionality.
Provides a simple if-then conditionality.
<p:if
test = expression
select = expression
equals = value>
<!-- Content: p:with-param*, template -->
</p:if>
Either test or select and an operator (e.g.
equals ) should be defined.
Example:
<p:if test="@has_title">This article has a title</p:if>
<p:if test="@has_title.not()">This article has no title</p:if>
<p:if select="@comments_count" equals="10">This article has 10 comments</p:if>
Parameters
- $args
array $args
- $patron
Patron\Engine
$patron
- $template
mixed $template
Throws
Exception
when both test and select are defined.
|
public static
|
#
markup_choose( array $args, Patron\Engine $patron, mixed $template )
Selects one among a number of possible alternatives.
Selects one among a number of possible alternatives.
<!-- Category: instruction -->
<p:choose>
<!-- Content: (p:when+, p:otherwise?) -->
</p:choose>
<p:when
test = boolean-expression>
<!-- Content: template -->
</p:when>
<p:otherwise>
<!-- Content: template -->
</p:otherwise>
It consists of a sequence of p:when elements followed by an
optional p:otherwise element. Each p:when element has
a single attribute, test, which specifies an expression. The content of the
p:when and p:otherwise elements is a template. When an
p:choose element is processed, each of the p:when
elements is tested in turn, by evaluating the expression and converting the
resulting object to a boolean as if by a call to the boolean function. The
content of the first, and only the first, p:when element whose test
is true is instantiated. If no p:when is true, the content of the
p:otherwise element is instantiated. If no p:when
element is true, and no p:otherwise element is present, nothing is
created.
Parameters
- $args
array $args
- $patron
Patron\Engine
$patron
- $template
mixed $template
|
public static
|
#
markup_variable( array $args, Patron\Engine $patron, mixed $template )
Binds a name to a value.
<!-- Category: top-level-element -->
<!-- Category: instruction -->
<p:variable
name = qname
select = expression>
<!-- Content: p:with-param*, template? -->
</p:variable>
<!-- Category: top-level-element -->
<p:param
name = qname
select = expression>
<!-- Content: template? -->
</p:param>
The value to which a variable is bound (the value of the variable) can be an
object of any of the types that can be returned by expressions. There are two
elements that can be used to bind variables: p:variable and
p:with-param . The difference is that the value specified on the
p:with-param variable is only a default value for the binding; when
the template within which the p:with-param element occurs is
invoked, parameters may be passed that are used in place of the default
values.
Both p:variable and p:with-param have a required
name attribute, which specifies the name of the variable. The value of the name
attribute is a qualified name.
Example:
<p:variable name="count" select="@comments_count" />
<p:variable name="count">There are #{@comments_count} comments</p:variable>
Parameters
- $args
array $args
- $patron
Patron\Engine
$patron
- $template
mixed $template
|
public static
|
#
markup_with( array $args, Patron\Engine $patron, mixed $template )
Parses a template with a bounded value.
Parses a template with a bounded value.
<p:with
select = expression>
<!-- Content: p:with-param*, template -->
</p:with>
Example:
<p:with select="articles.first().comments.last()">
Last comment: <a href="#{@url}">#{@title}</a>
</p:with>
Parameters
- $args
array $args
- $patron
Patron\Engine
$patron
- $template
mixed $template
|
public static
|
#
markup_translate( array $args, Patron\Engine $patron, mixed $template )
Translates and interpolates a string.
Translates and interpolates a string.
<p:translate
native = string>
<!-- Content: p:with-param* -->
</p:translate>
The arguments for the interpolation are provided using the attributes of the
markup, or the with-param construction.
Example:
<p:translate native="Posted on :date by !name">
<p:with-param name="date"><time datetime="#{@date}" pubdate="pubdate">#{@date.format_date()}</time></p:with-param>
<p:with-param name="name" select="@user.name" />
</p:translate>
Parameters
- $args
array $args
- $patron
Patron\Engine
$patron
- $template
mixed $template
|
public static
|
#
markup_decorate( array $args, Patron\Engine $engine, mixed $template )
Decorates a content with a template.
Decorates a content with a template.
<p:decorate
with = string>
<!-- Content: p:with-param*, template -->
</p:decorate>
The content of the markup is rendered to create the component to decorate, it
is then passed to the decorating template as the component
variable.
The name of the decorating template is specified with the with
attribute, and is interpolated e.g. if "page" is specified the templates
"@page.html" or "partials/@page.html" are used, which ever comes first.
The parameters specified using with-param are all turned into
variables.
Example:
<p:decorate with="page">
<p:page:content id="body" />
</p:decorate>
Parameters
- $args
array $args
- $engine
Patron\Engine
$engine
- $template
mixed $template
|