# sste

> Super Simple Template Engine

Latest version **1.0.0** (published 2018-02-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install sste
pnpm add sste
yarn add sste
bun add sste
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-02-22 |
| First published | 2018-02-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vitor Ruivo |
| Maintainers | vruivo |
| Keywords | simple, template, engine |

## Links

- npm: https://www.npmjs.com/package/sste
- Repository: https://github.com/vruivo/sste
- Homepage: https://github.com/vruivo/sste#readme
- Issues: https://github.com/vruivo/sste/issues
- npm.io page: https://npm.io/package/sste

## Recent versions

- 1.0.0 (latest) — 2018-02-22

## README

# Super Simple Template Engine

### What is it?
A simple, and synchronous, template engine aimed for server side use.

### How to use?
Load a template file into a sste object using either a string (and use the default tag markings) or an object (and define your tags) as argument,
and then pass it the values you want to populate the template with.

**Using a string argument (that uses the default tags `${` and `}`)**
```javascript
var sste = require('sste');

var tx = sste.loadTemplate(template_file);
var doc = tx.createFromTemplate( {'name':'A'} );
```

**Or an object argument**
```javascript
var sste = require('sste');

var tx = sste.loadTemplate( {
  'template': template_file,
  'tag_start': '${',
  'tag_end': '}'
});
var doc = tx.createFromTemplate( {'name':'A'} );
```

### Some examples:
* **Simple:**  

  template.txt
  ```
  Hello ${name}
  ```
  js
  ```javascript
  var sste = require('sste');

  var tx = sste.loadTemplate('template.txt');
  console.log( tx.createFromTemplate( {'name':'testing...'} ) )  // >> Hello testing...
  console.log( tx.createFromTemplate( {'name':'World!'} ) )      // >> Hello World!
  ```

* **Multiple tags:**

  template.txt
  ```
  The ${var1} ${var2} ${var3}
  ```
  js
  ```javascript
  var sste = require('sste');

  var tx = sste.loadTemplate('template.txt');

  console.log( tx.createFromTemplate({
    'var1':'quick',
    'var2':'brown',
    'var3':'fox'
  } ) );  // >> The quick brown fox

  console.log( tx.createFromTemplate({
    'var1':'magic',
    'var2':'ninja',
    'var3':'turtle'
  } ) );  // >> The magic ninja turtle
  ```

* **HTML, different tag markings, function for values:**  

  template.html
  ```
  <ul>
    %[items]
  </ul>
  ```
  js  
  ```javascript
  var sste = require('sste');

  var tx = sste.loadTemplate({
   'template':'template.html',
   'tag_start':'%[',
   'tag_end':']'
  });

  var doc = tx.createFromTemplate({
    'items': (function () {
      return '<li>One</li>\n  <li>Two</li>\n  <li>Three</li>';
    })()
  });
  console.log(doc);
  // >> <ul>
  // >>   <li>One</li>
  // >>   <li>Two</li>
  // >>   <li>Three</li>
  // >> </ul>
  ```

#### ...you can use it with anything that is text based, like JSON, XML, YAML...

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