Skip to content

Instantly share code, notes, and snippets.

@atelierbram
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atelierbram/e425ad7238af56925f7f to your computer and use it in GitHub Desktop.
Save atelierbram/e425ad7238af56925f7f to your computer and use it in GitHub Desktop.

Layout

Create a page named layout.hbs

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>{{title}}</title>
  </head>
  <body>
  <!-- conditionally `button` when `foo` is true -->
  {{#if foo}}
    {{> button }}
  {{/if}}
  <body>
    {% body %}
  </body>
</html>

Then tell Assemble where to find it:

assemble.layouts('templates/layouts/*.hbs');

Page

Create a page named foo.hbs or whatever you want:

---
layout: default
foo: true
---

This is a random page. We could put the “if” block here 
instead of the layout. Whatever makes sense for your project.
We’ll tell assemble how to find pages in the task defined below.  

Partial

Create a partial named button.hbs:

<button>Click me!!!</button>

then tell Assemble where to find it:

assemble.partials('templates/partials/*.hbs');

All together

Run assemble

var assemble = require('assemble');
var extname = require('gulp-extname');

assemble.partials('templates/partials/*.hbs');
assemble.layouts('templates/layouts/*.hbs');

assemble.task('default', function () {
  assemble.src('templates/*.hbs')
    .pipe(extname())
    .pipe(assemble.dest('.'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment