This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(resolved-view): use ResolvedViewStrategy instead of Container.ins…
…tance
- Loading branch information
1 parent
52a4eed
commit db85ea1
Showing
5 changed files
with
71 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {ViewManager} from './view-manager'; | ||
import {viewStrategy} from 'aurelia-templating'; | ||
import {relativeToFile} from 'aurelia-path'; | ||
/** | ||
* A view strategy that loads a view based on namespace and view name registered with the ViewManager | ||
*/ | ||
@viewStrategy() | ||
export class ResolvedViewStrategy { | ||
/** | ||
* Creates an instance of ResolvedViewStrategy. | ||
* @param namespace The namespace of the view. | ||
* @param view The name of the view. | ||
*/ | ||
constructor(namespace: string, view: string) { | ||
this.namespace = namespace; | ||
this.view = view; | ||
} | ||
|
||
/** | ||
* Loads a view factory. | ||
* @param viewEngine The view engine to use during the load process. | ||
* @param compileInstruction Additional instructions to use during compilation of the view. | ||
* @param loadContext The loading context used for loading all resources and dependencies. | ||
* @return A promise for the view factory that is produced by this strategy. | ||
*/ | ||
loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext?: ResourceLoadContext): Promise<ViewFactory> { | ||
let viewManager = viewEngine.container.get(ViewManager); | ||
let path = viewManager.resolve(this.namespace, this.view); | ||
|
||
compileInstruction.associatedModuleId = this.moduleId; | ||
return viewEngine.loadViewFactory(this.moduleId ? relativeToFile(path, this.moduleId) : path, compileInstruction, loadContext); | ||
} | ||
} |