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

templater.js

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

templater.js

Minimal JavaScript templating.

latest
Source
npmnpm
Version
3.1.1
Version published
Maintainers
1
Created
Source

templater.js

Build Status GitHub License

Dead-simple JavaScript templating with a tiny1 footprint. View the website for extended details & documentation.

Inspired by http://jsforallof.us/2014/12/01/the-anatomy-of-a-simple-templating-engine/ and http://krasimirtsonev.com/blog/article/Javascript-template-engine-in-just-20-line.

1 < 1KB minified + gzipped.

Quick Start

  • Install the script

    The script can be installed with Bower, npm, or by grabbing the latest release from GitHub.

    bower install templaterjs # For Bower
    npm install templater.js # For npm
    
  • Load in the script

    If in a browser environment, with a <script> tag

    <script src="path/to/templater.min.js"></script>
    

    Or, if in a Node.js environment with a require()

    var templater = require("templater.js");
    
  • Create the template

    <!-- by giving it a non-standard `type` the browser will ignore it -->
    <script id="template" type="text/template">
    <h1>Hi, I'm {{name}}.</h1>
    </script>
    
  • Use template and render it against some data

    var template = templater(document.getElementById("template").innerHTML),
        context = {
          name: "Paul"
        };
    
    console.log(template(context)); // <h1>Hi, I'm Paul.</h1>
    

Documentation

For further documentation and resources, visit the templater.js website.

Contributing

If you'd like to fork the repo and submit pull request, please feel free.

Check out CONTRIBUTING.md for specifics.

FAQs

Package last updated on 16 Feb 2025

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