Standalone build of Monkberry for use in browsers.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.npmignore
README.md
package.json
test.html
webpack.config.js

README.md

Monkberry Standalone

Standalone build of Monkberry for use in browsers.

CDN

https://cdn.jsdelivr.net/npm/monkberry-standalone@latest/monkberry.min.js

other versions on jsDelivr

Usage

Include it to your page.

<script src="https://cdn.jsdelivr.net/npm/monkberry-standalone@latest/monkberry.min.js"></script>

Define template with text/monkberry.

<script type="text/monkberry" id="component">
    <h1>
        Hello, {{ name }}!
    </h1>
</script>

And you now can get access to component template.

var view = Monkberry.render(component, document.body);

Mark node with data-monkberry attribule and it will be replaced with real view of Monkberry.

<div data-monkberry="app">
    <component name="world"></component>
    <p>This is {{ name || 'noname' }}.</p>
</div>

To get view instanse call Monkberry.getView method.

  var view = Monkberry.getView('app');
  view.update({name: 'Anton'});

Also with monkberry-standalone you can compile source code to JavaScript code.

var code = '<div>{{ text }}</div>';
var source = Monkberry.compile('name', code);