Search Results for

    Show / Hide Table of Contents
    View Source

    Class ViewHelper

    Provides helper methods for working with template view files.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.IO
    Assembly: Umbraco.Core.dll
    Syntax
    public class ViewHelper : IViewHelper

    Constructors

    View Source

    ViewHelper(FileSystems, IDefaultViewContentProvider)

    Initializes a new instance of the ViewHelper class.

    Declaration
    public ViewHelper(FileSystems fileSystems, IDefaultViewContentProvider defaultViewContentProvider)
    Parameters
    Type Name Description
    FileSystems fileSystems

    The file systems provider.

    IDefaultViewContentProvider defaultViewContentProvider

    The default view content provider.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when any required parameter is null.

    Methods

    View Source

    CreateView(ITemplate, bool)

    Creates a view file for the specified template.

    Declaration
    public 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.

    View Source

    GetFileContents(ITemplate)

    Gets the file contents of the specified template's view file.

    Declaration
    public 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.

    View Source

    UpdateViewFile(ITemplate, string?)

    Updates the view file for the specified template.

    Declaration
    public 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.

    View Source

    ViewExists(ITemplate)

    Determines whether a view file exists for the specified template.

    Declaration
    public bool ViewExists(ITemplate t)
    Parameters
    Type Name Description
    ITemplate t

    The template to check.

    Returns
    Type Description
    bool

    true if the view file exists; otherwise, false.

    View Source

    ViewPath(string)

    Gets the relative path to a view file based on the template alias.

    Declaration
    public string ViewPath(string alias)
    Parameters
    Type Name Description
    string alias

    The template alias.

    Returns
    Type Description
    string

    The relative path to the view file.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX