can-view-import
Import dependencies in Stache views.
API
can-view-import function
<can-import from="MODULE_NAME" />
Statically import a module from with a [can-stache] template. MODULE_NAME will be imported before the template renders.
<can-import from="components/tabs" />
<tabs-widget />
- MODULE_NAME
{moduleName}
:
A module that this template depends on.
<can-import from="MODULE_NAME">content</can-import>
Dynamically import a module. MODULE_NAME will be imported dynamically; the scope within the template is a Promise.
<can-import from="components/tabs">
{{#if isResolved}}
<tabs-widget />
{{/if}}
</can-import>
- MODULE_NAME
{moduleName}
:
A module that this template depends on.
from="MODULE_NAME"
Passes MODULE_NAME to [can-util/js/import/import] and sets the 's viewModel to be the returned Promise.
<can-import from="bootstrap/bootstrap.css" />
- MODULE_NAME
{String}
:
The name of the module to import.
can-tag="TAG_NAME"
Instantiates the provided [can-view-callbacks.tag] and sets its [can-component::viewModel viewModel] to be the Promise for the import.
- TAG_NAME
{String}
:
The tag name (usually a [can-component]) to use.
{^value}="*NAME"
Sets up a [can-stache-bindings.toParent] binding to *NAME in the references scope.
- NAME
{String}
:
The variable name to assign to the references scope. This can be any string name you want to use, but must be preceded by *
or it will be placed on the template's View Model.
<can-import from="app/person" {^value}="*person" />
<section>
hello {{*person.name}}
</section>
Contributing
Making a Build
To make a build of the distributables into dist/
in the cloned repository run
npm install
node build
Running the tests
Tests can run in the browser by opening a webserver and visiting the test.html
page.
Automated tests that run the tests from the command line in Firefox can be run with
npm test