0.3.3 • Published 7 years ago

redoculous v0.3.3

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

redoculous Build Status

An async template library in the style of PHP. Try it out!

  • Use the entire power of the node runtime.
  • Handle asynchronous code easily with await
  • Identify errors fast with accurate stack traces.

Example

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<String>

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

<?doc
// you have a full node environment to play around in
const foo = "World";
const bar = require("./module");
?>

# Interpolate exported values easily with: <?= foo ?>


<?doc
// all code is run inside an async function
const result = await new Promise(res => setTimeout(
  res,
  500,
  "value"
));
?>

The result is <?= result ?>


<?doc
// you can also interpolate code and text
for (let i = 0; i < 10; i++) { ?>
repeating <?= i ?> times
<?doc } ?>
0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago