examples/HTML StarterKit/lib/durandal/js/viewLocator.js
function(viewOrUrlOrId, area, elementsToSearch) {
            if (typeof viewOrUrlOrId === 'string') {
                var viewId;

                if (viewEngine.isViewUrl(viewOrUrlOrId)) {
                    viewId = viewEngine.convertViewUrlToViewId(viewOrUrlOrId);
                } else {
                    viewId = viewOrUrlOrId;
                }

                if (area) {
                    viewId = this.translateViewIdToArea(viewId, area);
                }

                if (elementsToSearch) {
                    var existing = findInElements(elementsToSearch, viewId);
                    if (existing) {
                        return system.defer(function(dfd) {
                            dfd.resolve(existing);
                        }).promise();
                    }
                }

                return viewEngine.createView(viewId);
            }

            return system.defer(function(dfd) {
                dfd.resolve(viewOrUrlOrId);
            }).promise();
        }
function(viewOrUrlOrId, area, elementsToSearch) {
            if (typeof viewOrUrlOrId === 'string') {
                var viewId;

                if (viewEngine.isViewUrl(viewOrUrlOrId)) {
                    viewId = viewEngine.convertViewUrlToViewId(viewOrUrlOrId);
                } else {
                    viewId = viewOrUrlOrId;
                }

                if (area) {
                    viewId = this.translateViewIdToArea(viewId, area);
                }

                if (elementsToSearch) {
                    var existing = findInElements(elementsToSearch, viewId);
                    if (existing) {
                        return system.defer(function(dfd) {
                            dfd.resolve(existing);
                        }).promise();
                    }
                }

                return viewEngine.createView(viewId);
            }

            return system.defer(function(dfd) {
                dfd.resolve(viewOrUrlOrId);
            }).promise();
        }
function ( viewOrUrlOrId , area , elementsToSearch ) { if ( typeof viewOrUrlOrId === 'string' ) { var viewId ; if ( viewEngine . isViewUrl ( viewOrUrlOrId ) ) { viewId = viewEngine . convertViewUrlToViewId ( viewOrUrlOrId ) ; } else { viewId = viewOrUrlOrId ; } if ( area ) { viewId = this . translateViewIdToArea ( viewId , area ) ; } if ( elementsToSearch ) { var existing = findInElements ( elementsToSearch , viewId ) ; if ( existing ) { return system . defer ( function ( dfd ) { dfd . resolve ( existing ) ; } ) . promise ( ) ; } } return viewEngine . createView ( viewId ) ; } return system . defer ( function ( dfd ) { dfd . resolve ( viewOrUrlOrId ) ; } ) . promise ( ) ; }
Locates the specified view.
@method locateView
@param {string|DOMElement} viewOrUrlOrId A view, view url or view id to locate.
@param {string} [area] The area to translate the view to.
@param {DOMElement[]} [elementsToSearch] An existing set of elements to search first.
@return {Promise} A promise of the view.
Locates the specified view .