npm package: @novigi/template-engine
Description: Zero dependency stand-alone general purpose template engine for super fast templating 🛠
Author: Novigi
Latest version: 1.0.0-1

![npm (scoped)](https://img.shields.io/npm/v/@novigi/template-engine) ![NPM](https://img.shields.io/npm/l/@novigi/template-engine) ![Statements](https://img.shields.io/badge/statements-100%25-brightgreen.svg?style=flat) ![Branches](https://img.shields.io/badge/branches-100%25-brightgreen.svg?style=flat) ![Functions](https://img.shields.io/badge/functions-100%25-brightgreen.svg?style=flat) ![Lines](https://img.shields.io/badge/lines-100%25-brightgreen.svg?style=flat)
# @novigi/template-engine

Zero dependency stand-alone general purpose template engine for super fast templating 🛠

## 🐿 Features

- Supports nested obejects → `'${deeply.nested.objects.are.supported}'`
- Reusable templates → you can have the template in a varable!
- lightweight, error free and super fast templating
- Javascript template literals style

## 📦 Getting Started

1. Install the dependency
```
npm install @novigi/template-engine
```

2. Import the library
```
const lib = require('@novigi/template-engine');
```

## 📖 Documentation

<a name="module_template"></a>

## template
Templates enable fast rendering of the server-side data that needs to be passed to the application.The template engine replaces the variables in a template file with actual values, and displays this value to the client. This makes it easier to quickly build our application. This is the guideline of compile-time text rendering capability.

```js
const { template } = require('@novigi/template-engine')

template.render('We are from ${city}!', {city: 'Colombo'})  // We are from Colombo
// or simply
'We are from ${city}!'.render({city: 'Colombo'})            // We are from Colombo
```


* [template](#module_template)
    * _static_
        * [.render(templatedText, context)](#module_template.render) ⇒ <code>string</code>
    * _inner_
        * [~String](#external_String)
            * [.render(context)](#external_String+render) ⇒ <code>String</code>

<a name="module_template.render"></a>

### template.render(templatedText, context) ⇒ <code>string</code>
This function render a text, based on the templatedText and contextObject.

**Kind**: static method of [<code>template</code>](#module_template)  
**Returns**: <code>string</code> - rendered text  

| Param | Type | Description |
| --- | --- | --- |
| templatedText | <code>string</code> | templated text that needs to be replaced with context objects values |
| context | <code>object</code> | object that contains values for template |

**Example**  
```js
template.render('${city} is a coastal city', {city: 'Sydney'})  // Sydney is a coastal city

let ctx = {
 location: {
    city: {
      state: 'NSW'
    }
  }
}
template.render('${location.city.state} is the state!', ctx)   // NSW is the state!
```
<a name="external_String"></a>

### template~String
Extension methods to built in String object.

**Kind**: inner external of [<code>template</code>](#module_template)  
<a name="external_String+render"></a>

#### string.render(context) ⇒ <code>String</code>
Extension method to the String object to call `render()` method with context object.

**Kind**: instance method of [<code>String</code>](#external_String)  
**Returns**: <code>String</code> - rendered text  

| Param | Type | Description |
| --- | --- | --- |
| context | <code>object</code> | object that contains values for template |

**Example**  
```js
'We are from ${city}!'.render({city: 'Colombo'})   // We are from Colombo
```

_This is an auto generated file. Please don't make changes manually_