A module that automatically renders script and other elements with the can-autorender attribute. This function is useful to know when the templates have finished rendering.
Registers functions to callback when all templates successfully render or an error in rendering happens.
A function to callback when all autorendered templates have been rendered successfully.
A function to callback if a template was not rendered successfully.
As long is this module is part of your CanJS build or imported with RequireJS, StealJS, or SystemJS, can-autorender will automatically look for
can-autorendertags and render them. Once all templates have finished rendering, it will call any callbacks passed to
For example, you might have a page like:
If the template source is a
<script>tag within the
<body>, the rendered template is placed immediately following the template.
<script>tag is outside the body, for example in the
<head>tag, the rendered result will be placed just before the closing
If the template source is any other element, the element's contents will be replaced with the rendered result. For example:
The template is rendered with a can.Map made from the attributes of the template source element. That
mapis available on the template source element via can.viewModel. You can change the map at any time:
You can change attributes on the element and it will update the viewModel too:
For demo pages that require very little setup:
For demo pages that require a little custom setup:
Error callbacks will be called if a template has a parsing error or a