|
|
@@ -277,11 +277,18 @@ app.get('/examples/:repoSlug/:slug',
|
|
|
var example = _.find(req.repo.examples, { slug });
|
|
|
const { title, html, js, css, libsCss, libsJs } = example;
|
|
|
console.log(example, title, html, js, css, libsCss, libsJs);
|
|
|
- readFileAsync(__dirname + '/exemples/' + repoSlug + '/' + slug + '/example.html')
|
|
|
+ readFileAsync(examplesDir + '/' + repoSlug + '/' + slug + '/example.html')
|
|
|
.then(body =>
|
|
|
- Mustache.render(sandboxTpml, { body, repoSlug, slug, title, js, css, libsCss, libsJs })
|
|
|
+ Mustache.render(sandboxTpml, {
|
|
|
+ body, repoSlug, slug, title, js, css, libsCss, libsJs,
|
|
|
+ examplesDir: path.relative(__dirname, examplesDir)
|
|
|
+ })
|
|
|
)
|
|
|
- .then(html => res.send(html));
|
|
|
+ .then(html => res.send(html))
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err);
|
|
|
+ res.status(500).send('Error: ' + err.message);
|
|
|
+ });
|
|
|
}
|
|
|
);
|
|
|
|