New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-inject-template

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-inject-template

Inject underscore template file into main html file inside script tag

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

node-inject-template

Inject underscore template file into main html file inside script tag.

Installation

npm install node-inject-template

Launch

node ./node_modules/node-inject-template/index.js dest=index.html folder=templates

That command take two options :

  • dest : destination file whete templates content will be injected
  • folder : folder who containes all templates to inject

In this case all files in templates folder will be injected in index.html file.

Special comment

Before run command you must add that html comment in destination file :

<!-- #! template -->
<!-- ## template -->

Example

index.html file :

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Test</title>
    </head>
    <body>
        <!-- #! template -->
        <!-- ## template -->
    </body>
</html>

A templates file in templates folder, main-view.html

<h1>
    <% _.first(['hello']) %> world
</h1>

Result after command (output file is actually not prettyfied) :

    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="UTF-8">
            <title>Test</title>
        </head>
        <body>
            <!-- #! template -->
            <script type="text/template" id="template-1">
                <h1>
                    <% _.first(['hello']) %> world
                </h1>
            </script>
            <!-- ## template -->
        </body>
    </html>

TODO

  • Create grunt plugin
  • Add possibility to run command without node ./node_modules/node-inject-template/index.js

Changelog

1.0.2

  • Reset destination file before inject template

Keywords

node

FAQs

Package last updated on 16 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts