Skip to content

Commit

Permalink
feat(compose): view and view-model are now relative
Browse files Browse the repository at this point in the history
When you set the view or view-model properties on the composer element
to a string value, indicating a module/view path, those paths are now
relative to the containing view.
  • Loading branch information
EisenbergEffect committed Dec 18, 2014
1 parent eec3118 commit 0b54a75
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
ViewSlot,
NoView,
UseView,
ViewEngine
ViewEngine,
ViewResources
} from 'aurelia-templating';

export class Compose {
Expand All @@ -20,12 +21,13 @@ export class Compose {
];
}

static inject(){ return [Container,ResourceCoordinator,ViewEngine,ViewSlot]; }
constructor(container, resourceCoordinator, viewEngine, viewSlot){
static inject(){ return [Container,ResourceCoordinator,ViewEngine,ViewSlot,ViewResources]; }
constructor(container, resourceCoordinator, viewEngine, viewSlot, viewResources){
this.container = container;
this.resourceCoordinator = resourceCoordinator;
this.viewEngine = viewEngine;
this.viewSlot = viewSlot;
this.viewResources = viewResources;
}

bind(executionContext){
Expand Down Expand Up @@ -75,9 +77,13 @@ function processBehavior(composer, instruction, behavior){
function processInstruction(composer, instruction){
var useView, result, options, childContainer;

if(typeof instruction.viewModel == 'string'){
//TODO: make instruction.viewModel relative to compose's containing view
composer.resourceCoordinator.loadAnonymousElement(composer.viewModel, null, instruction.view).then(type => {
if(instruction.view){
instruction.view = composer.viewResources.relativeToView(instruction.view);
}

if(typeof instruction.viewModel === 'string'){
instruction.viewModel = composer.viewResources.relativeToView(instruction.viewModel);
composer.resourceCoordinator.loadAnonymousElement(instruction.viewModel, null, instruction.view).then(type => {
childContainer= composer.container.createChild();
options = {suppressBind:true};
result = type.create(childContainer, options);
Expand All @@ -86,7 +92,6 @@ function processInstruction(composer, instruction){
});
}else{
if(instruction.view) {
//TODO: make instruction.view relative to compose's containing view
useView = new UseView(instruction.view);
}

Expand Down

0 comments on commit 0b54a75

Please sign in to comment.