handlebars-extend-block

add extend blocks to handlebars

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
handlebars-extend-block
2111.0.08 years ago8 years agoMinified + gzip package size for handlebars-extend-block in KB

Readme

handlebars-extend-block
Create extend blocks for handlebars allowing partials to inject text into parent elements. This is generally useful for script and style tags.

example

var handlebars = require('handlebars');
var extend = require('handlebars-extend-block');

handlebars = extend(handlebars);

Layout File
<head>
    <title>{{title}}</title>
    <link rel='stylesheet' href='/css/style.css'>
    {{{block "stylesheets"}}}
</head>

<body>
    {{{body}}}

    <hr/>
    post body
    <hr/>

    {{{block "scripts"}}}
</body>

Partial
{{#extend "stylesheets"}}
<link rel="stylesheet" href="/css/index.css"/>
{{/extend}}

let the magic begin

{{#extend "scripts"}}
<script>
document.write('foo bar!');
</script>
{{/extend}}