Skip to content

Supporting jade includes #45

Description

@tstone

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?

https://github.com/tstone/bogart/commit/0df477cd822bc02ccaacf240657ca1d265df383f
https://github.com/tstone/bogart-jade/commit/5f9d943450d06f43e61ed7974d56feb131652e28

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions