yahoo/js-intl-docs — pull request #17 by tilomitra (2014-06-24 15:55:49+00:00)
Title: Server-render React, Dust and HBS examples, expose source code to client

This PR adds a `getExamples()` function that helps with retrieving all examples for a specific template engine (React, Dust, or HBS) and render them out server-side, while exposing the source-code for the example to the client, to help with client-side Intl.

## Usage in JS
Inside your route handler, you can call it like this:

### handlebars.js (route handler)
```js
var getExamples = require('../lib/examples');
getExamples('handlebars', {cache: true}).then(function (examples) {
//do something with the examples object here
res.render('handlebars', {
examples: examples
});
});
```

And then inside your `handlebars.hbs` file, you can use the `{{examples}}` context:

### handlebars.hbs (template):

```handlebars

{{{examples.books.rendered}}}

{{#code}}
{{{examples.books.source}}}
{{/code}}
```

I've modified the Dust, React and HBS route handlers to already do the above, and I have some simple examples there.

## Examples Directory

All the examples now live inside `views/examples/`. There's a directory for each template engine and we can add more if needed. Don't put any examples in `views/partials/`. We should use partials only for website stuff.