‚̧Neverending Package Mountain
    Wondering what‚Äôs next for npm?Check out our public roadmap! ¬Ľ

    This package has been deprecated

    Author message:

    use @voliware/node-data-transform

    @voliware/node-inject

    0.1.3¬†‚Äʬ†Public¬†‚Äʬ†Published

    node-inject

    Inject data into another file based on tags

    How to Use it

    Suppose you want to inject HTML templates into a main HTML file. For example, you are building a shop page and you want to inject a shopping cart icon and an item list table.

    /templates/itemlist.html

    <table id="itemlist">
        <thead>
            <tr>
                <th>Name</th>
                <th>Price</th>
            </tr>
        </thead>
    </table>

    /templates/shoppingcart.html

    <div id="shoppingcart">
        <div id="carticon"></div>
        <div id="itemcount"></div>
        <div id="paynow"></div>
    </div>

    Into a main HTML file

    /templates/index.html

    <!doctype html>
    <html lang="en">
        <head>
            <title>Shop</title>
        </head>
        <body>
            <!-- inject:itemlist -->
            <!-- inject:shoppingcart -->
        </body>
    </html>

    Just write and execute the following code

    const Inject = require('@voliware/node-inject');
    let inject = new Inject()
        .inject("./templates/itemlist.html", 'itemlist')
        .inject("./templates/shoppingcart.html", 'shoppingcart')
        .into("./templates/index.html")
        .saveas("./index.html")
        .run();

    And you'll end up with

    <!doctype html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
            <title>Shop</title>
        </head>
        <body>
            <table id="itemlist">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Price</th>
                    </tr>
                </thead>
            </table>
            <div id="shoppingcart">
                <div id="carticon"></div>
                <div id="itemcount"></div>
                <div id="paynow"></div>
            </div>
        </body>
    </html>

    Node

    Install with node package manager

    npm install @voliware/node-inject

    Include in a file

    const Inject = require('@voliware/node-inject');

    Install

    npm i @voliware/node-inject

    DownloadsWeekly Downloads

    0

    Version

    0.1.3

    License

    MIT

    Unpacked Size

    15.3 kB

    Total Files

    11

    Last publish

    Collaborators

    • avatar