Socket
Book a DemoInstallSign in
Socket

non-literal

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

non-literal

Abusing ES6 literal templates to be non-literal so you can load from a file or tempalte script element

0.0.3
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

non-literal

A module to make ES6 templates work non-literally so you can load templates from strings, files, DOM Elements, etc.

Installation

npm install non-literal --save

Usage

Simple string variable template

  var nonLiteral = require('non-literal'),
      // this string could be read from a file, database, localization mechanism, etc.
      template = 'Hi ${name}, your score was ${score}!',
      model = {
        name: "Mike",
        score: 97
      };
  console.log(nonLiteral.render(model, template));

Simple string variable template outputting html with html entity encoding by default

Using renderHtml() ${ } will encode html entities, $${ } will output 'raw', without encoding

  var nonLiteral = require('non-literal'),
      // this string could be read from a file, database, localization mechanism, etc.
      template = '<section><strong>${label}:</strong> ${content} $${markup}</section>',
      model = {
        label: "Message",
        content: "Rain storms & silence are my <mind palace>",
        markup: "&#128526;"
      };
  console.log(nonLiteral.renderHtml(model, template));

Keywords

Template

FAQs

Package last updated on 22 Mar 2017

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.