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
ファイルを表示 Open project: andrewdavey/knapsack Class Usage Examples

Public Methods

Method 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

Method 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 method

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
return System

ReferenceExternalScript() public method

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".
return void

ReferenceScript() public method

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.
return void

ReferenceStylesheet() public method

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.
return void

RenderScripts() public method

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.
return IHtmlString

RenderStylesheetLinks() public method

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

ReplacePlaceholders() public method

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.
return string