App Extensions - Razor and Views
Extensions can include custom Razor Views for re-use.
Tip
This allows you to create small libraries of Razor which solve a specific problem, and then share them across multiple Apps by installing the extension in each App.
For Razor extensions, you may choose to create one or more of the following:
- Razor views (
/extensions/{ExtensionName}/{ViewName}.cshtmlfiles) for rendering content.
...possibly including the view definition, so it's selectable in the template picker. - Razor partial views for reusable components.
- Razor base classes for shared logic, to be used in other Razor files.
Location and Naming
While developing Razor extensions,
just place them in the /extensions/{ExtensionName}/ folder of your extension.
You may also choose to place them in a sub-folder like Views or Razor to keep things organized.
We suggest that you go for a clear naming, such as:
- Standard views:
/extensions/{ExtensionName}/{ViewName}.cshtml - Partial views:
/extensions/{ExtensionName}/Part {Something}.cshtml - Base classes:
AppCode/Extensions/{ExtensionName}/{Something}Base.cs
Packaging & export
Tip
Razor files are only exported if they are specified in the extension configuration.
To include Razor files in an extension:
Open the extension configuration of the extension
Enable Has Razor Files (but only if you include view definitions)
Include in the Package Definition
Tip
To include them in the extension, you must ensure that it's part of the package export.
The package export system only exports parts which have been declared to be in use. So make sure to tick the "Has Query" checkbox in the extension's package definition UI.
If you plan to include view definitions, make sure you also tick the "Has View" checkbox, and that the view definition is in the data (which must also be exported...)
History
- Beta in v20.09, to be released in v21.00
- Updated Pictures