Nourishing Plushie Monster

    kisphp-format-string

    1.1.2 • Public • Published

    Javascript Format String

    pipeline status

    This repository started as a need to replace text in javascript in tiny templates without a framework.

    Installation

    npm install --save kisphp-format-string
    

    Integrate script

    require('kisphp-format-string');

    Or simply include the js file in your browser

    <script async src="node_modules/kisphp-format-string/src/format-string.js"></script>

    Usage

    var data = {
        name: "John Doe",
        info: "Software Engineer"
    };
    
    var template_1 = '<div><h3>{name}</h3><h5>{info}</h5></div>';
    var template_2 = '<div><h3>{0}</h3><h5>{1}</h5></div>';
    
    // use with object 
    console.log(template_1.formatString(data));
    
    // use with direct elements
    console.log(template_2.formatString(data.name, data.info));
    
    // use with array
    console.log(template_2.formatString([
        data.name, 
        data.info
    ]));

    Install

    npm i kisphp-format-string

    DownloadsWeekly Downloads

    17

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    6.34 kB

    Total Files

    6

    Last publish

    Collaborators

    • kisphp