Newly Potted Mandrakes

    This package has been deprecated

    Author message:

    This package has been deprecated. Use deep-template instead.

    curry-template

    1.0.4 • Public • Published

    curry-template

    Create curried templates from common JS structures using ES6 syntax

    Install

    In a browser:

    <script src="curry-template.js"></script>

    Using npm:

    $ npm i -g npm
    $ npm i --save curry-template

    Usage

    curryTemplate(String, Object) -> String

    var curryTemplate = require('curry-template');
    var buildPath = curryTemplate('/api/users/${id}/');
    buildPath({id: '549873456448'}); // -> "/api/users/549873456448/"

    curryTemplate(Object, Object) -> Object

    var configTemplate = {
        a: ['/api/users/${id}/${action}'],
        b: { 
            deep: {
                foo: [
                    { 
                        stuff: 'DEFAULT_ENV=${env}'
                    }
                ] 
            }
        },
        c: function() { console.log('avoided') },
        d: /keepRegExp/gim,
        e: 'keep simple texts',
        f: 10
    };
    var defaults = {action: 'defaultAction', env: '/usr/bin/bash'};
    var configBuilder = curryTemplate(configTemplate, defaults);
    configBuilder({id: '549873456448'}); 
    /* -> {
            a: ["/api/users/549873456448/defaultAction"],
            b: {
                deep: {
                    foo: [{
                        stuff: "DEFAULT_ENV=/usr/bin/bash"
                    }]
                }
            },
            c: function() { console.log('avoided') },
            d: /keepRegExp/gim,
            e: "keep simple texts",
            f: 10
        }
    */

    curryTemplate(String, Array) -> String

    var arrayBuildPath = curryTemplate('/api/users/${0}/${1}/${2}', [null, null, 'ascending']);
    arrayBuildPath(['549873456448', 'getUser']); // -> "/api/users/549873456448/getUser/ascending"

    Install

    npm i curry-template

    DownloadsWeekly Downloads

    0

    Version

    1.0.4

    License

    MIT

    Last publish

    Collaborators

    • leodutra