Interface DurandalViewEngineModule

Index

Properties

Methods

Properties

public viewExtension: string

The file extension that view source files are expected to have.

default

.html

public viewPlugin: string

The name of the RequireJS loader plugin used by the viewLocator to obtain the view source. (Use requirejs to map the plugin's full path).

default

text

public viewPluginParameters: string

Parameters passed to the RequireJS loader plugin used by the viewLocator to obtain the view source.

default

The empty string by default.

Methods

public convertViewIdToRequirePath(viewId: string): string

Converts a view id into a full RequireJS path.

Parameters

  • viewId: string

    The view id to convert.

Returns

string

The require path.

public convertViewUrlToViewId(url: string): string

Converts a view url into a view id.

Parameters

  • url: string

    The url to convert.

Returns

string

The view id.

public createFallbackView(viewId: string, requirePath: string, err: Error): JQueryPromise

Called when a view cannot be found to provide the opportunity to locate or generate a fallback view. Mainly used to ease development.

Parameters

  • viewId: string

    The view id whose view should be created.

  • requirePath: string

    The require path that was attempted.

  • err: Error

Returns

JQueryPromise

A promise for the fallback view.

public createView(viewId: string): JQueryPromise

Creates the view associated with the view id.

Parameters

  • viewId: string

    The view id whose view should be created.

Returns

JQueryPromise

A promise of the view.

public ensureSingleElement(allElements: Array<Node>): HTMLElement

Converts an array of elements into a single element. White space and comments are removed. If a single element does not remain, then the elements are wrapped.

Parameters

  • allElements: Array<Node>

    The elements.

Returns

HTMLElement

A single element.

public isViewUrl(url: string): boolean

Determines if the url is a url for a view, according to the view engine.

Parameters

  • url: string

    The potential view url.

Returns

boolean

True if the url is a view url, false otherwise.

public parseMarkup(markup: string): Array<Node>

Parses the view engine recognized markup and returns DOM elements.

Parameters

  • markup: string

    The markup to parse.

Returns

Array<Node>

The elements.

public processMarkup(markup: string): HTMLElement

Calls parseMarkup and then pipes the results through ensureSingleElement.

Parameters

  • markup: string

    The markup to process.

Returns

HTMLElement

The view.

public putViewInCache(id: string, view: HTMLElement): any

Puts the view associated with the id into the cache of parsed views.

Parameters

  • id: string

    The view id whose view should be cached.

  • view: HTMLElement

    The view to cache.

Returns

any

public tryGetViewFromCache(id: string): HTMLElement

Gets the view associated with the id from the cache of parsed views.

Parameters

  • id: string

    The view id to lookup in the cache.

Returns

HTMLElement

The cached view or null if it's not in the cache.