# non-literal

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

Latest version **0.0.3** (published 2017-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install non-literal
pnpm add non-literal
yarn add non-literal
bun add non-literal
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2017-03-22 |
| First published | 2017-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mike Scalora |
| Maintainers | mscalora |
| Keywords | Template, Cross Platform, ES6 |

## Links

- npm: https://www.npmjs.com/package/non-literal
- Repository: https://github.com/mscalora/non-literal
- Issues: https://github.com/mscalora/non-literal/issues
- npm.io page: https://npm.io/package/non-literal

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2017-03-22
- 0.0.2 — 2017-03-20
- 0.0.1 — 2017-03-20

## README

# 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

```javascript
  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  

```javascript
  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));
```

---
_Source: https://npm.io/package/non-literal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
