These are chat archives for canjs/canjs

5th
Aug 2015
Matthew Phillips
@matthewp
Aug 05 2015 16:31
@gsmeets awesome! i'll take a look at it, does it work with the requirejs optimizer?
Guido Smeets
@gsmeets
Aug 05 2015 21:56

@matthewp it's intended to be used with it. if you create this:

define(["stache!path/to/template.stache], function ( VIEW ) {})

then VIEW will be the renderer function. The plugin loader will pull in the file and run it through can.stache.async, which in turn will fetch any can-imports and partials.

When building with requirejs it'll wrap the template in a can.stache(). The pluginbuilder will find all can-imports and partials and add those in the define() that is being generated.

i.e., if the template.stache is:

<can-import from="app/foo/bar" />
<my-foo />

then this will be the generated result:

define([ "can", "can/stache", "app/foo/bar", function( can ) {
    return can.stache( " <can-import from="app/foo/bar" /><my-foo />" );
})