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

<render>

Within a partial file, renders the material wrapped by the reference to that partial file.

Usage: anyXml2<render/>anyXml4

Given: anyXml1<partialFileName>anyXml3</partialFileName>anyXml5

Results in C#:

//anyXml1-generated-code
{
  //anyXml2-generated-code
  {
    //anyXml3-generated-code
  }
  //anyXml4-generated-code
}
//anyXml5-generated-code

When <render/> appears in a partial template it generates code for the contents of the element which referenced the partial. This can be used to have a partial file which "wraps" any sort of contained material in the parent template. This enabled partials to be used as content wrappers to produce rounded corners or ajax effects for example around arbitrary content.

with segment="" (previously known as 'section' before HTML5 was born)

Usage: anyXml2<render segment="anyName"/>anyXml4

Given: anyXml1<partialFileName><segment name="anyName">anyXml3</segment></partialFileName>anyXml5

Results in C#:

//anyXml1-generated-code
{
  //anyXml2-generated-code
  {
    //anyXml3-generated-code
  }
  //anyXml4-generated-code
}
//anyXml5-generated-code

When <render segment=""/> appears in a partial template it renders the contents of the <segment name=""> contained in the referencing <render partial=""> template. This enables partials to render several distinct micro-templates, for example a repeater partial could have top/bottom/even/odd named segments.

See also: <segment/>

with *="" assignments

Usage: anyXml2<render x="a" y="b"/>anyXml4

Given: anyXml1<partialFileName>anyXml3</partialFileName>anyXml5

Results in C#:

//anyXml1-generated-code
{
  //anyXml2-generated-code
  {
    var x = a;
    var y = b;
    //anyXml3-generated-code
  }
  //anyXml4-generated-code
}
//anyXml5-generated-code

Partial files may declare local variables when rendering passed in content. They are available to the scope of the wrapped content or named segment in the outer template file.

with fall-back content

Usage: anyXml2<render segment="anyName" x="a" y="b">anyXml-fall-back </render>anyXml4

Given: anyXml1<partialFileName/>anyXml5

Results in C#:

//anyXml1-generated-code
{
  //anyXml2-generated-code
  {
    var x = a;
    var y = b;
    //anyXml-fall-back-generated-code
  }
  //anyXml4-generated-code
}
//anyXml5-generated-code

When the reference to a partial file is empty, or the named segment does not exist, the contents of the <render> element in the partial file will generate the rendering code by default.

Given: anyXml1<partialFileName>anyXml3</partialFileName>anyXml5

Results in C#:

//anyXml1-generated-code
{
  //anyXml2-generated-code
  {
    var x = a;
    var y = b;
    //anyXml3-generated-code
  }
  //anyXml4-generated-code
}
//anyXml5-generated-code

When the reference to a partial file has contents, the contents of the <render> element in the partial file is unused.

<render partial="" />

Includes the contents of a partial file for rendering at the point where it appears.

Usage: <render partial="_partialFileName"/>

Alias: <partialFileName/>

Results in C#:

{
  //_partialFileName.spark-generated-code
}

Partial files may have any name, but usually start with _ by convention. The name without the underscore may then be used as a short version of the <render/> element.

with *="" assignments

<render partial="_partialFileName" x="a" y="b"/>

Results in C#:

{
  var x = a;
  var y = b;
  //_partialFileName.spark-generated-code
}

A partial file reference may declare local variables. They are available to the scope of the wrapped content or named segment.