Template declaration
To declare a new template, create a new script
element:
<script type="text/karkas" name="yourTemplateName"> // Template body </script>
Compilation
You can specify special tags on HTML element to make Karkas compile that element on page load.
<div data-compile='{"foo": "bar"}' data-view='MyView' data-k-on-compile='onElementCompile();'> ... </div>
List of attributes:
data-compile
- JSON to compile (required)data-view
- Template to use. If not defined - inner content of the element will be used as template. (optional)data-k-on-compile
- Hook to evaluate on template compile. Passes current element as first argument. (optional)
Detect changes
By default, Karkas runs HTML scan after DOMContentLoaded
event.
You can call karkas.refresh()
to process new HTML elements.