-
Notifications
You must be signed in to change notification settings - Fork 86
use element
Ensures a partially or fully qualified assembly name is include when the Spark assembly is compiled.
<use assembly="system.something.something"/>
or
<use assembly="system.something.something, etc=20394824, etc=239483432"/>
Renders whatever has been captured in a named content spool.
<use content="x"/>
Results in C#:
if (Contents.ContainsKey("x"))
{
Output.Write(Contents["x"]);
}
The use of content spooling is actually very efficient. It uses pooled pages of string references to replay the original output, which doesn't increase memory pressure and avoids string copying and concatenation costs.
There is a built-in content spool named view
that is the default if no name is given.
<use content="x">anyXml-fall-back </use>
Results in C#:
if (Contents.ContainsKey("x"))
{
Output.Write(Contents["x"]);
}
else
{
// anyXml-fall-back-generated-code
}
If the named content segment has never been written into the fall-back output is generated. This can be used for default title contents, for example:
<title><use content="title">My Default Title</use></content>
or for wrapping any html in the layout you may want to entirely replace in some views.
An alias for <render partial=""/>
.
<use file="_partialFileName"/>
All behavior is identical to render partial.
Includes all of the elements which have a global effect declared in a template.
<use import="fileName"/>
This can be used to organize elements like <viewdata/>
, <global/>
, <macro/>
, <use import=""/>
, <use assembly=""/>
, <use namespace=""/>
into importable template files for greater manageability.
The well-known file named _global.spark
in the current template's directory, and in the Shared
directory, is automatically imported.
Forces the layout around the current template file to become the named file.
<use master="fileName"/>
This will override the master which would normally have been used. Multi-level rendering can be accomplished by chaining templates with use master="xyz"
elements.
This element has no effect when it's in a partial file or import file.
Uses a dotnet namespace in the generated code.
<use namespace="any.name.space"/>
Results in C#:
using any.name.space;
Uses a namespace. Frequently placed in an import file like _global.spark
.