Created
May 5, 2018 01:16
-
-
Save jonschlinkert/813916ebbe6653fccdadd7fbfa97d81b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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