RunKit + npm: handlebars-layouts

node v11.15.0
endpointsharetweet
var handlebars = require("handlebars"); var layouts = require("handlebars-layouts"); layouts.register(handlebars); handlebars.registerPartial('layout', ` Hello from layout.hbs {{#block "styles"}}{{/block}} {{#block "from-page"}}{{/block}} `); handlebars.registerPartial('component', ` Hello from component.hbs {{#content 'styles' mode='append'}} <link href="/css/bar.css" rel="stylesheet"> {{/content}} `); const template = handlebars.compile(` {{#extend "layout"}} {{#content 'styles' mode='append'}} <link href="/css/foo.css" rel="stylesheet"> {{/content}} {{#content "from-page"}} Hello from page.hbs {{#embed "component"}}{{/embed}} {{/content}} {{/extend}} `); template();
Created from: https://npm.runkit.com/handlebars-layouts
Loading…