Skip to content
RobertTheGrey edited this page Jan 12, 2013 · 1 revision

<use assembly="" />

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"/>

<use content="" />

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.

with fall-back content

<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.

<use file="" />

An alias for <render partial=""/>.

<use file="_partialFileName"/>

All behavior is identical to render partial.

<use import="" />

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.

<use master="" />

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.

<use namespace="" />

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.