Reference Source

assets/templates/template.js

/**
 * Wrap a string literal
 * @param strings
 * @param keys
 * @returns {Function}
 */
export const template = (strings, ...keys) => {
    return ((...values) => {
        const dict = values[values.length - 1] || {};
        const result = [strings[0]];
        keys.forEach(function (key, i) {
            const value = Number.isInteger(key) ? values[key] : dict[key];
            result.push(value, strings[i + 1]);
        });
        return result.join('');
    });
};