Interface IViewHelper
Provides helper methods for working with template view files.
Namespace: Umbraco.Cms.Core.IO
Assembly: Umbraco.Core.dll
Syntax
public interface IViewHelper
Methods
View SourceCreateView(ITemplate, bool)
Creates a view file for the specified template.
Declaration
string CreateView(ITemplate t, bool overWrite = false)
Parameters
| Type | Name | Description |
|---|---|---|
| ITemplate | t | The template to create a view for. |
| bool | overWrite | Whether to overwrite an existing view file. |
Returns
| Type | Description |
|---|---|
| string | The contents of the view file. |
GetFileContents(ITemplate)
Gets the file contents of the specified template's view file.
Declaration
string GetFileContents(ITemplate t)
Parameters
| Type | Name | Description |
|---|---|---|
| ITemplate | t | The template to get contents for. |
Returns
| Type | Description |
|---|---|
| string | The contents of the view file, or an empty string if the file does not exist. |
UpdateViewFile(ITemplate, string?)
Updates the view file for the specified template.
Declaration
string? UpdateViewFile(ITemplate t, string? currentAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ITemplate | t | The template to update the view for. |
| string | currentAlias | The current alias of the template, used to rename the file if the alias has changed. |
Returns
| Type | Description |
|---|---|
| string | The content of the updated view file. |
ViewExists(ITemplate)
Determines whether a view file exists for the specified template.
Declaration
bool ViewExists(ITemplate t)
Parameters
| Type | Name | Description |
|---|---|---|
| ITemplate | t | The template to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
ViewPath(string)
Gets the relative path to a view file based on the template alias.
Declaration
string ViewPath(string alias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias | The template alias. |
Returns
| Type | Description |
|---|---|
| string | The relative path to the view file. |