An open API service indexing awesome lists of open source software.

https://github.com/nickclaw/redoculous


https://github.com/nickclaw/redoculous

async documentation nodejs template-engine

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

          

# redoculous [![Build Status](https://travis-ci.org/nickclaw/redoculous.svg?branch=master)](https://travis-ci.org/nickclaw/redoculous)

An async template library in the style of PHP. [Try it out!](https://npm.runkit.com/redoculous)
- Use the entire power of the node runtime.
- Handle asynchronous code easily with `await`
- Identify errors fast with [accurate stack traces](/test/blame.test.js).

### Example

```js
import render from 'redoculous';
import fs from 'fs';

const path = '/path/to/template.md.doc';
const raw = fs.readFileSync(path);

render({
template: raw,
filepath: path,
globals: { foo: 'bar' }
}).then(
text => console.log(text),
err => console.error(err),
);
```

### API

##### `render(options: Object) -> Promise`
Process a template into text. Takes the following options:
- `template: String` the template to render
- `filepath: String` where to resolve `require` from
- `globals: ?Object` the initial variables your template can use

### Syntax

```php

# Interpolate exported values easily with: = foo ?>

setTimeout(
res,
500,
"value"
));
?>

The result is = result ?>

repeating = i ?> times

```