Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: handlebars-layouts
node v11.15.0
endpoint
share
tweet
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…
Clone and edit this document