shannonmoeller / handlebars-layouts

Handlebars helpers which implement layout blocks similar to Jinja, Nunjucks (Swig), Pug (Jade), and Twig.
http://npm.im/handlebars-layouts
MIT License
361 stars 29 forks source link

{{#embed}} causes Assemble 0.6.x to fail build #19

Closed spacedawwwg closed 9 years ago

spacedawwwg commented 9 years ago

All has been working great with handlebars-layouts and Assemble 0.6.x until I tried to use {{#embed}}

Gulpfile:

// Config
var config = {
  src: 'src/',
  dist: 'dist/',
  scripts: 'scripts/',
  styles: 'styles/',
  images: 'images/'
}

// Include Gulp
var gulp = require('gulp');

// Include general plugins
var plugins = require('gulp-load-plugins')({
  pattern: [
    'gulp-*',
    'del',
    'browser-sync'
  ]
});

var reload = plugins.browserSync.reload;

// Include Assemble & Helpers
var assemble = require('assemble');
var handlebars = require('handlebars');
var helpers = {
  layouts: require('handlebars-layouts'),
  repeat: require('handlebars-helper-repeat')
};
// Register Helpers
handlebars.registerHelper(helpers.layouts(handlebars));
handlebars.registerHelper('repeat', helpers.repeat);
handlebars.registerHelper('either', function () {
  var options = arguments[arguments.length - 1];
  for (var i = 0; i < arguments.length - 1; i++) {
    if (arguments[i]) {
      return options.fn(this);
    }
  }
  return options.inverse(this);
});

// Build Markup
gulp.task('markup-compile', function () {
  assemble.layouts(config.src + 'templates/**/*.hbs');
  assemble.partials(config.src + 'templates/components/**/*.hbs');
  assemble.pages(config.src + 'pages/*.hbs');
  assemble.data([config.src + 'data/**/*.{json,yml}']);
  gulp.src(config.src + 'pages/*.hbs')
    .pipe(plugins.plumber())
    .pipe(plugins.assemble(assemble, {
      scripts: config.scripts,
      styles: config.styles,
      images: config.images
    }))
    .pipe(plugins.extname())
    .pipe(gulp.dest(config.dist));
});

Layout:


---
layout: layout--blank

---
{{#block "layout--blank__body"}}{{/block}}

Partial:


---
component: panel

---
{{#extend "layout--blank"}}
  {{#content "layout--blank__body"}}
    <section class="panel {{modifier}} {{class}}" id="{{id}}">
      <div class="panel__inner">
        {{#if title}}
        <header class="panel__header">
          <h3 class="panel__title">{{title}}</h3>
        </header>
        {{/if}}
        {{#if @content.body}}
        <div class="panel__body">
          {{#block "body"}}{{/block}}
        </div>
        {{/if}}
      </div>
    </section>
  {{/content}}
{{/extend}}

Page:


---
page-title: Builder

---
{{#extend "layout--a"}}
  {{#content "region--a"}}
    {{partial "page-header" builder}}
    {{partial "page-controls"}}
  {{/content}}
  {{#content "region--b"}}
    Sidebar
  {{/content}}
  {{#content "region--c"}}
    {{#each builder.panels}}
      {{#embed "panel" this}}
        {{#content "body"}}Body Text{{/content}}
      {{/embed}}
    {{/each}}
  {{/content}}
{{/extend}}

Causes this error:

screen shot 2015-04-24 at 13 27 31

shannonmoeller commented 9 years ago

Change {{#embed "panel" this}} to just {{#embed "panel"}}.

spacedawwwg commented 9 years ago

Thanks for getting back so quick! Unfortunately, that results in the same error.

spacedawwwg commented 9 years ago

I have a feeling this is Assemble and not the helpers that are causing this

spacedawwwg commented 9 years ago

Decided this is an issue related to Assemble/template-render, so closing.

P.S - Dumped Assemble and started using gulp-hb... the week is back on track!