Different foot block per page

60 views Asked by At

I have this custom handelbars helper

// custom-helper.js
module.exports = function(name, options) {
  if (!this._sections) {
    this.sections = {};
  }
  this._sections[name] = options.fn(this);
  return null;
};

// register with assemble
var app = assemble();
app.helper('section', require('./custom-helper.js'));

How to Register custom handelbars helper in assemble 0.17.1

This helper should work like here:

Handlebars with Express: different html head for different pages

And in my grunt Project is does work perfectly. But in this gulp Project it´s not working.

My Layout.hbs:

<body>
  <div id="page">
    {%body%}
  </div>
  {{{_sections.foot}}}
</body>

My pages that contain the _sections.foot content and the rest of the page content:

--- layout: default.hbs ---

<h1>Body Blah Blah</h1>
<p>This goes in page body.</p>

{{#section 'foot'}} my custom per page foot content {{/section}}

What the code should do is to tage the custom content in my pages, that is this:

{{#section 'foot'}} my custom per page foot content {{/section}}

and render it in the place that I defined in the layout:

{{{_sections.foot}}}

When I run my gulp task or assemble task I get this. "null" is written in my rendered .html file at the position in my page.hbs, thats directly under the pages content inside #page and not after #page where my layout.hbs says to put it in.

Here are the Problems: 1. Null is rendered and not the content. 2. Even if the content would be rendered it would appear at the wrong position in html.

0

There are 0 answers