'use strict';

var Template = require('..');
var template = new Template();
var consolidate = require('consolidate');
var matter = require('gray-matter');
var utils = require('parser-utils');
var _ = require('lodash');


template.engine('hbs', consolidate.handlebars);

var engine = template.getEngine('hbs').helpers;

engine.addHelper('include', function (filepath) {
  return fs.readFileSync(filepath, 'utf8');
});


template.page('home.hbs', 'this is content.');
template.partial('sidebar.hbs', '<section>Sidebar</section>');
template.partial('navbar.hbs', '<nav><ul><li>link</li></ul></nav>');

template.layout('default.hbs', [
  '<!DOCTYPE html>',
  '<html lang="en">',
  '  <head>',
  '    <meta charset="UTF-8">',
  '    <title>{{title}}</title>',
  '  </head>',
  '  <body>',
  '    {% body %}',
  '  </body>',
  '</html>'
].join('\n'));


var file = {path: 'about.hbs', content: '{{name}}', name: 'Jon Schlinkert'};
template.render(file, function (err, content) {
  if (err) console.log(err);
  console.log(content);
});

  var inspect = require('util').inspect;
  console.log(inspect(template, null, 10));
@@ -334,15 +334,11 @@
 er('
-include
+foo
 ', f
@@ -350,70 +350,96 @@
 on (
-filepath) %7B%0A  return fs.readFileSync(filepath, 'utf8');
+value) %7B%0A  console.log(this)%0A  return value;%0A%7D);%0A%0Atemplate.data(%7B%0A  title: 'Site!'
 %0A%7D);%0A%0A
-%0A
 temp
@@ -477,24 +477,112 @@
 content.');%0A
+template.page('about.hbs','%7B%7Bname%7D%7D', %7Bname: 'Jon Schlinkert', layout: 'default.hbs'%7D);%0A
 template.par
@@ -628,16 +628,18 @@
 section%3E
+%5Cn
 ');%0Atemp
@@ -885,24 +885,84 @@
 '  %3Cbody%3E',%0A
+  '    %7B%7B%3E sidebar.hbs %7D%7D',%0A  '    %7B%7Bpartial %22home.hbs%22%7D%7D',%0A
   '    %7B%25 bo
@@ -1013,16 +1013,19 @@
 n'));%0A%0A%0A
+// 
 var file
@@ -1094,11 +1094,37 @@
 ert'
-%7D;%0A
+, layout: 'default.hbs'%7D;%0A// 
 temp
@@ -1167,16 +1167,19 @@
 tent) %7B%0A
+// 
   if (er
@@ -1199,16 +1199,19 @@
 g(err);%0A
+// 
   consol
@@ -1230,14 +1230,161 @@
 t);%0A
+// 
 %7D);%0A%0A
- 
+template.render('about.hbs', function (err, content) %7B%0A  if (err) console.log(err);%0A  console.log(content);%0A%7D);%0A%0A  // console.log(template);%0A%0A%0A//
  var
@@ -1419,17 +1419,18 @@
 nspect;%0A
- 
+//
  console

update example