Skip to content

Instantly share code, notes, and snippets.

@jonschlinkert
Created May 5, 2018 01:16
Show Gist options
  • Save jonschlinkert/813916ebbe6653fccdadd7fbfa97d81b to your computer and use it in GitHub Desktop.
Save jonschlinkert/813916ebbe6653fccdadd7fbfa97d81b to your computer and use it in GitHub Desktop.
(async function() {
const handlebars = require('handlebars');
const engine = require('./examples/support/engine');
const Assemble = require('./');
const app = new Assemble();
app.engine('hbs', engine(handlebars));
const pages = app.create('pages');
const layouts = app.create('layouts', { kind: 'layout' });
const view = await pages.set('templates/foo.hbs', {
contents: Buffer.from('Name: {{name}}, {{description}}'),
data: { name: 'Brian' },
layout: 'default'
});
await layouts.set({ path: 'foo', contents: Buffer.from('before {% body %} after') });
await layouts.set({ path: 'base', contents: Buffer.from('before {% body %} after'), layout: 'foo' });
await layouts.set({ path: 'default', contents: Buffer.from('before {% body %} after'), layout: 'base' });
let count = 1000000;
console.time('layout');
while (count--) {
await app.render(view, { description: 'This is page: ' + count });
}
console.timeEnd('layout')
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment