On This Page
Snippets
Snippets
Snippets are a special kind of subtemplate that are defined inline. Snippets are useful when multiple portions of a single template should reference the same logic or structure.
Creating Snippets
Snippets are similar to subtemplates but can be defined in the same file as where they are used.
Snippets are defined using the syntax
A common use of a snippet is to repeat portions of a template in two locations, for instance to display some content as a link if href
is defined.
Snippet Location - Snippets are not dependent on the order they are included and can be defined either before and after where they are invoked.
Data Context
By default a snippet inherits its parents data context, but you can modify its data context by passing in data
Snippet Example
This example shows a common pattern of using a snippet to define a table row