nrstott/bogart — Issue #45: Supporting jade includes
Author: tstone
Created: 2012-01-22 02:18:36+00:00
State: open

The jade template engine requires the variable `filename` to be set to the absolute path of the template file in order for includes to work right.

It's possible to achieve this within a route handler...

router.get('/', function() {
return viewEngine.respond('index.jade', { filename: path.join(__dirname,'/views/index.jade') });
});

...but that's kind of a pain. This could be solved a number of ways, but one way it can't is in the jade adapter. As implemented, bogart doesn't pass this information back to the template engine so when jade is added as a template engine it's rendering function can't automatically handle this.

As a solution to this, the viewEngine could pass the viewPath (along with the view and whatever else) back to the template engine for those engines that need it. I forked bogart and implemented this on my fork as a 5th parameter on the engine callback.

Where it was `function(template, opts, cache, viewEngine)`

It is now `function(template, opts, cache, viewEngine, meta)`

Does this sound like a solution that makes sense or is there a better approach?