call
Syntax
call template-name (parameter-name = value) {
/* code */
}Description
Call a named template. You can pass parameters
into the template by including a comma-separated list of parameters,
with the parameter name and an optional equal sign (=) and value expression. If a value is not specified, the current
value of the parameter is passed to the template.
You can declare additional parameters inside the code block
using the with statement.
Attributes
template-name |
Specifies the name of the template to call. |
SLAX Example
match configuration {
var $name-servers = name-servers/name;
call temp();
call temp($name-servers, $size = count($name-servers));
call temp() {
with $name-servers;
with $size = count($name-servers);
}
template temp($name-servers, $size = 0) {
<output> "template called with size " _ $size;
}
}XSLT Equivalent
<xsl:template match="configuration">
<xsl:variable name="name-servers" select="name-servers/name"/>
<xsl:call-template name="temp"/>
<xsl:call-template name="temp">
<xsl:with-param name="name-servers" select="$name-servers"/>
<xsl:with-param name="size" select="count($name-servers)"/>
</xsl:call-template>
<xsl:call-template name="temp">
<xsl:with-param name="name-servers" select="$name-servers"/>
<xsl:with-param name="size" select="count($name-servers)"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="temp">
<xsl:param name="name-servers"/>
<xsl:param name="size" select="0"/>
<output>
<xsl:value-of select="concat('template called with size ', $size)"/>
</output>
</xsl:template>Usage Examples
See Example: Require and Restrict Configuration Statements, Example: Impose a Minimum MTU Setting, and Example: Automatically Configure Logical Interfaces and IP Addresses.
Release Information
Statement introduced in version 1.0 of the SLAX language.