Snippet

Snippets make it possible to render markup from a source template anywhere, regardless of the context and the usual rendering order.

This is particularly useful for assigning dynamic values to e.g. Facebook's Open Graph metadata tag; normally you would not have access to e.g. product information in the master template, but by defining a snippet in the product details template and using RenderSnippet() in the master template you do.

Define a snippet source with SnippetStart and SnippetEnd tags. 

If there are 2 identical snippet content sections, they are stacked in order of appearance.

Select the code snippet in your template like this:

@SnippetStart("mySnippet") ..some code to move... @SnippetEnd("mySnippet")

Insert this tag where the snippet should be rendered (same or another template):

@RenderSnippet("mySnippet")

In HTML:

<!--@SnippetStart(mySnippet)--> ..some code to move... <!--@SnippetEnd(mySnippet)--> <!--@Snippet(mySnippet)-->