Fork me on GitHub


DOM templating made natural


ist.js v0.6.6 - Small new features

09 March 2014 permalink

I just released ist.js version 0.6.6, which adds two new features (one of which was actually added in 0.6.5 but I didn't write a post about it).

The first one enables defining global variables or helpers that will be available anywhere in templates:"myHelper", function(value) {
    return "helped value: " + value;
});"myValue", 42);
    /* Renders to "helped value: hi!" */
    "{{ myHelper('hi!') }}"

    /* Renders to "42" */
    "{{ myValue }}"

Note that context variables with the same name as global variables will take precedence, as you're used to in Javascript.

The second features enable escaping newlines with a backslash to make long selectors more readable. All spaces/tabs before the backslash and on the beginning of the following line will be ignored. Take care not to leave spaces after the escaping backslash.

div.class#id[data-one={{ one }}][data-two={{ two }}] \
    [data-three={{ three }}][data-four={{four }}] \
            [data-five={{ five }}][data-six={{ six }}]