Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to configure Bliss Templating in express js?

How to configure Bliss Templating in express js?

Problem

I was trying what I've seen in other questions with no luck:

  • Express.js custom template engine (plate)
  • node.js + express.js + dust.js issues

I tried to override the default engine configuration with

app.register('.js.html', {
    compiler: function(str,options){...}
});

but register is undefined in express js.

I got Bliss working this way

exports.index = function(req, res){
    //res.render('index', {});
    res.send(bliss.render(__dirname+"/index",{}));
};

but I'd like to use res.render('index',output) instead.

Problem courtesy of: jorfx

Solution

You have to set it up this way:

var Bliss = new require('bliss');
var bliss = new Bliss();
app.engine('.bliss',function(path,options,fn){
    fn(null,bliss.render(path, options));
});

Then you call it like this:

exports.index = function(req, res){
  res.render('user.bliss', { title: 'Express' });
};

You need a file called user.bliss under the views directory

Solution courtesy of: Raymi

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

How to configure Bliss Templating in express js?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×