Closed ghost closed 10 years ago
Updated for errors in my 'fix'. I'll stop posting now! Actually think I figured it out. Created an instance (as per your README) and then did this:
var express = require('express');
var handlebars = require('handlebars');
var exphbs = require('express3-handlebars');
var exphbspart = require('express3-handlebars').create();
var routes = require('./routes');
var http = require('http');
var path = require('path');
//swag for handlebars
var Swag = require('swag');
Swag.registerHelpers(handlebars);
// EXPRESS
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
// Register `hbs.engine` with the Express app.
var hbs = exphbs.create({layoutsDir:'views/layouts/', partialsDir:'views/partials/', defaultLayout: 'main', extname:'.handlebars'});
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');
exphbspart.loadPartials(function (err, partials) {
console.log(partials);
// => { 'foo.bar': [Function],
// => title: [Function] }
});
Once I read your source code and saw the way you have extended Handlebars and RTM, I got it to work for me (for now). Thanks and sorry for asking the dumb question!
Is it possible to use SWAG https://github.com/elving/swag with exphbs? And could you recommend a good implementation of it / example?
This is how I have started it, but I'm sure I'm missing something and would this conflict (using different modules)?
Sorry for the noob question and hope ok to ask here.