<commit_before>Retriever
=========

A simple / lightweight JavaScript template engine<commit_msg>Modified README<commit_after>Retriever
=========

A simple / lightweight JavaScript template engine ( node / browser )

## Documentation

Class document is available:

---

## How to build ( for browser )

Install task / test tool at global:

```
npm install -g grunt-cli mocha
```

Install development npms

```
npm install .
```

Run the build task

```
grunt build
```

---

## Basic Usage

`Retriever.make(template)` and `parse(params)` will returns parsed string.

### In node

Simple require and call method.

```
var Retriever = require('retriever');
var template  = 'Hello, {{libName}}!'
var bind      = { libName: 'Retriever' };

// will returns 'Hello, Retriever!'
var result = Retriever.make(template).parse(bind);
```

### In browser

Load a build-scripta and call method.

```
<script src="build/retriever.min.js"></script>
<script>
var template = 'Hello, {{libName}}!'
var bind     = { libName: 'Retriever' };

// will returns 'Hello, Retriever!'
var result = Retriever.make(template).parse(bind);
</script>
```

## Supported sections

### if-elseif-else

```
var template = "{{if dat == 'foo'}}foo{{else if dat == 'bar'}}bar{{else}}baz{{/if}}"
var bind     = { dat: 'bar' };

// will returns 'bar'
var result = Retriever.make(template).parse(bind);
```

#### Supported features

- Relational operators: `>`, `<`, `>=`, `<=`, `==`. `===`, `!=`, `!==`
- Logical operators: `&&`, `||`
- Calculation like: `{{if a + b > 100 * 10}}` ( a, b is supplied from parser parameter )

### loop

```
var template = "{{loop section}}{{value}}{{/loop}}"
var bind     = {
    section: [
        { value: 'foo' },
        { value: 'bar' },
        { value: 'baz' }
    ]
};

// will returns 'foobarbaz'
var result = Retriever.make(template).parse(bind);
```

And Enable to use nested section.


{'fraction_non_alphanumeric': 0.19703389830508475, 'fraction_numerical': 0.0026483050847457626, 'mean_word_length': 3.7462311557788945, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6139878', 'n_tokens_mistral': 655, 'n_tokens_neox': 624, 'n_words': 176}