I'm new in Handlebars and I'm trying to use SWAG library for custom helpers but unsuccess. For example I try to display in my file.handlebars {{lowercase "BENDER SHOULD NOT BE ALLOWED ON TV"}} and I get the error Error: Could not find property 'lowercase' I ran npm install swag
my app.js is:
var express = require('express')
, http = require('http')
, routes = require('./routes')
, path = require('path')
,Swag = require('swag')
, handlebars = require('handlebars');
var app = express();
var engines = require('consolidate');
app.engine('handlebars', engines.handlebars);
app.configure(function() {
app.set('view engine', 'handlebars');
app.set('views', __dirname + '/views');
app.set('port', process.env.PORT || 3000);
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
app.get('/dashBoard', routes.getDashboard);
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
Thank in advance for your help
Alcudia
I'm not 100% sure, but my guess is that consolidate package returns it's own locale copy of Handlebars. As so, it is not the Handlebars you required, and it is not a global Handlebars onto which swag is applied.
To schematise: require("Handlebars") !== require("consolidate").handlebars
So, my guess now is that you'll need to register the swags helper on the consolidate handlebars instance. (And there, I checked Swag code source and I don't thinks that's possible ATM)
You can try:
Swag.registerHelpers(Handlebars);