You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed in an email with @EisenbergEffect, could we please have a viewUrl property in the routes? At the moment it appears that Aurelia is simply taking the moduleId and appending a .js extension to find the model and an .html extension to find the view.
In order to use Razor routes, I make use of ViewLocator.prototype.convertOriginToViewUrl as follows:
ViewLocator.prototype.convertOriginToViewUrl = function (origin) {
//console.log("origin: " + JSON.stringify(origin));
var viewUrl = null;
var idx = origin.moduleId.indexOf('aurelia-app');
// The majority of views should be under /wwwroot/aurelia-app
if (idx != -1) {
viewUrl = origin.moduleId.substring(idx + 11).replace(".js", '');
}
// JSPM packages may need to load HTML files (example: aurelia-kendoui-bridge)
// TODO: This is not perfect.. (what if the view we want to show is normal HTML, but not in jspm_packages folder?)
else if (origin.moduleId.indexOf('jspm_packages') !== -1) {
viewUrl = origin.moduleId.replace(".js", '.html');
}
else {
// This is for any js files in top-level of /wwwroot directory (should point to HomeController).
var split = origin.moduleId.split("/");
viewUrl = split[split.length - 1].replace(".js", '');
}
console.log('View URL: ' + viewUrl);
return viewUrl;
}
If you look at it carefully, you will see it’s not quite perfect. I would actually prefer to not have to do this at all.. we could have Aurelia still look for .html files by default, but if there’s a viewUrl property in the route definition, then use that instead.. That way, modules that are not being served by ASP .NET controllers and have actual HTML files (for example: aurelia-kendo-bridge and others) won’t be affected... and it will allow me to have the .js file location decoupled from the .html file location, so I can put them wherever I want and additionally, I can then use embedded javascript as well. I did that with Durandal by passing the embedded script path to the RequireJS config.. but I currently don’t see a way of doing this in Aurelia.. and I absolutely need embedded js files in my architecture in some cases.
The text was updated successfully, but these errors were encountered:
I'm not sure a new viewUrl property will be a good name when/if the new component property is implemented. aurelia/templating-router#75
At least consider the above PR before implementing viewUrl :)!
As discussed in an email with @EisenbergEffect, could we please have a viewUrl property in the routes? At the moment it appears that Aurelia is simply taking the moduleId and appending a .js extension to find the model and an .html extension to find the view.
In order to use Razor routes, I make use of
ViewLocator.prototype.convertOriginToViewUrl
as follows:If you look at it carefully, you will see it’s not quite perfect. I would actually prefer to not have to do this at all.. we could have Aurelia still look for .html files by default, but if there’s a viewUrl property in the route definition, then use that instead.. That way, modules that are not being served by ASP .NET controllers and have actual HTML files (for example: aurelia-kendo-bridge and others) won’t be affected... and it will allow me to have the .js file location decoupled from the .html file location, so I can put them wherever I want and additionally, I can then use embedded javascript as well. I did that with Durandal by passing the embedded script path to the RequireJS config.. but I currently don’t see a way of doing this in Aurelia.. and I absolutely need embedded js files in my architecture in some cases.
The text was updated successfully, but these errors were encountered: