Simple binding

Bind an object to a list, using plain JavaScript inside the markup.

The smallest useful example. A template is ordinary HTML with #…# in it, and the expressions inside are plain JavaScript — no new language, no build step.

<!-- Simply code your template into your page -->
<div id="app">
    <h1>#title#</h1>
    <ul>
    #for(let item of items) {#
        <li>#item#</li>
    #}#
    </ul>
</div>

<!-- Run Javascript to bind data to the page -->
<script src="https://cdn.jsdelivr.net/gh/richdafunk/hashJS@v1.3.6/hashJS.js"></script> 
<script>
    const data = {
        title: 'My HashJS title',
        items: ['Item 1', 'Item 2', 'Item 3']
    };

    var h = new hashJS("app");
    h.bind(data);
</script>
Output result:

The template is compiled once into a JavaScript function, then called with your data. That is why #title# behaves exactly like title would in a .js file: it is the same expression, evaluated in the same way.

The same applies to #for(let item of items) {#. It is not an imitation of a loop — it compiles to a real for loop. Anything you can write in JavaScript, you can write here.