C# Class Knapsack.Web.PageHelper

Enables a page to reference client scripts and stylesheets. The required script and link elements can then be generated.
Inheritance: IPageHelper
Afficher le fichier Open project: andrewdavey/knapsack Class Usage Examples

Méthodes publiques

Méthode Description
PageHelper ( bool useModules, bool bufferHtmlOutput, string handler, IReferenceBuilder scriptReferenceBuilder, IReferenceBuilder stylesheetReferenceBuilder, string>.Func virtualPathToAbsolute ) : System
ReferenceExternalScript ( string externalScriptUrl, string location ) : void

Records that the calling view requires the given script. This does not render any HTML. Call RenderScripts to actually output the script elements.

ReferenceScript ( string scriptPathOrUrl ) : void

Records that the calling view requires the given script. This does not render any HTML. Call RenderScripts to actually output the script elements.

ReferenceStylesheet ( string stylesheetPath ) : void

Records that the calling view requires the given stylesheet. This does not render any HTML. Call RenderStylesheets to actually output the link elements.

RenderScripts ( string location ) : IHtmlString

Creates HTML script elements for all required scripts (tagged as having the given location) and their dependencies. When buffering HTML output, a placeholder is returned instead.

RenderStylesheetLinks ( ) : IHtmlString

Creates HTML link elements for all required stylesheets and their dependencies. When buffering HTML output, a placeholder is returned instead.

ReplacePlaceholders ( string line ) : string

When buffering HTML output, the line is checked for known script and stylesheet placeholders. They are replaced with the relevant HTML.

Private Methods

Méthode Description
AppRelativeScriptUrl ( Resource script ) : string
AppRelativeStylesheetUrl ( Resource stylesheet ) : string
BuildHtmlElements ( IEnumerable urls, string template ) : IEnumerable
CoffeeScriptUrl ( string path ) : string
CreateScriptsHtml ( string location ) : string
CreateStylesheetsHtml ( ) : string
DebugScriptUrl ( Resource resource ) : string
DebugScriptUrls ( string location ) : IEnumerable
DebugStylesheetUrls ( ) : IEnumerable
GetScriptsPlaceholder ( string location ) : string
ReleaseScriptUrl ( Module m ) : string
ReleaseScriptUrls ( string location ) : IEnumerable

Returns the application relative URL for each required script module. The hash of each module is appended to enable long-lived caching that is broken when a module changes.

ReleaseStylesheetUrls ( ) : IEnumerable

Returns the application relative URL for each required stylesheet module. The hash of each module is appended to enable long-lived caching that is broken when a module changes.

Method Details

PageHelper() public méthode

public PageHelper ( bool useModules, bool bufferHtmlOutput, string handler, IReferenceBuilder scriptReferenceBuilder, IReferenceBuilder stylesheetReferenceBuilder, string>.Func virtualPathToAbsolute ) : System
useModules bool
bufferHtmlOutput bool
handler string
scriptReferenceBuilder IReferenceBuilder
stylesheetReferenceBuilder IReferenceBuilder
virtualPathToAbsolute string>.Func
Résultat System

ReferenceExternalScript() public méthode

Records that the calling view requires the given script. This does not render any HTML. Call RenderScripts to actually output the script elements.
public ReferenceExternalScript ( string externalScriptUrl, string location ) : void
externalScriptUrl string
location string The location identifier for this script e.g. "head" or "body".
Résultat void

ReferenceScript() public méthode

Records that the calling view requires the given script. This does not render any HTML. Call RenderScripts to actually output the script elements.
public ReferenceScript ( string scriptPathOrUrl ) : void
scriptPathOrUrl string The application relative path to the script file or an absolute external script URL.
Résultat void

ReferenceStylesheet() public méthode

Records that the calling view requires the given stylesheet. This does not render any HTML. Call RenderStylesheets to actually output the link elements.
public ReferenceStylesheet ( string stylesheetPath ) : void
stylesheetPath string The application relative path to the stylesheet file.
Résultat void

RenderScripts() public méthode

Creates HTML script elements for all required scripts (tagged as having the given location) and their dependencies. When buffering HTML output, a placeholder is returned instead.
public RenderScripts ( string location ) : IHtmlString
location string The location being rendered.
Résultat IHtmlString

RenderStylesheetLinks() public méthode

Creates HTML link elements for all required stylesheets and their dependencies. When buffering HTML output, a placeholder is returned instead.
public RenderStylesheetLinks ( ) : IHtmlString
Résultat IHtmlString

ReplacePlaceholders() public méthode

When buffering HTML output, the line is checked for known script and stylesheet placeholders. They are replaced with the relevant HTML.
public ReplacePlaceholders ( string line ) : string
line string The line to check for placeholders.
Résultat string