New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create ~ helper for joining to the baseURL #1816
Comments
The base URL of the module loader is not necessarily the base URL of a website. The domain/authority part is not necessarily the base URL of a website either as you can host individual applications inside subdirectories. E.g. Application-relative URLs (the term used by Microsoft, which has been using a leading tilde for these type of URLs since the first version of ASP.NET) are best handled in user code, by having users describe how the base application url should be mapped. E.g. using RequireJS, the following does the job: <head>
<script>
// First create a module mapping for the '~' symbol to
// a domain-relative, protocol-relative or absolute root
// url. (Don't make it path relative! That won't work!)
require.config({
map : { "*" : {
"~" : "/application/."
}}
})
</script>
</head> define([ "require" ], function( require ) {
// Then use the `require.toUrl()` method.
// In this case, it will produce "/application/content/images/example.jpg"
var fullUri = require.toUrl( "~/content/images/example.jpg" );
}); |
Great point. We can allow the user to set a variable, probably |
The ~ helper is used to create urls (for `<img>` for example) that are bound to the root of your application or relative to the current module. If the lookup is relative, such as: ``` {{~ "../hello/world.svg"}} ``` This will lookup the location relative to the current template module (if using Steal). Otherwise it will lookup the location through, in descending importance: * can.baseUrl * System.baseUrl (if using Steal/System) * location.pathname Fixes #1816 Includes docs
The ~ helper is used to create urls (for `<img>` for example) that are bound to the root of your application or relative to the current module. If the lookup is relative, such as: ``` {{~ "../hello/world.svg"}} ``` This will lookup the location relative to the current template module (if using Steal). Otherwise it will lookup the location through, in descending importance: * can.baseUrl * System.baseUrl (if using Steal/System) * location.pathname Fixes #1816 Includes docs
When server-side rendering a separate loader is created that represents a loader that is actually loading the application in a browser. If the renderingLoader is present we should use it, and use its baseURL. This closes out #1816
When server-side rendering a separate loader is created that represents a loader that is actually loading the application in a browser. If the renderingLoader is present we should use it, and use its baseURL. This closes out #1816
This is in minor. |
This will be used to join to the root, for example images:
will convert to:
If the module loader's baseUrl is
https://somecdn.com/
~ path...
This will typecheck for StealJS/SystemJS, RequireJS, to get the module loader baseUrl, and fallback to document.baseURI to use as the base url that the arguments are joined to.
If the path is relative it will use the module's path, if available. #1817 is needed for that functionality.
The text was updated successfully, but these errors were encountered: