Import dependencies in CanJS views
JavaScript HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Build Status

Import dependencies in Stache views.


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 />
  1. 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 />
  1. MODULE_NAME {moduleName}: A module that this template depends on.


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" />
  1. MODULE_NAME {String}: The name of the module to import.


Instantiates the provided [can-view-callbacks.tag] and sets its [can-component::viewModel viewModel] to be the Promise for the import.

  1. TAG_NAME {String}: The tag name (usually a [can-component]) to use.


Sets up a [can-stache-bindings.toParent] binding to *NAME in the references scope.

  1. 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" />
      hello {{*}}


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