Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting jade includes #45

Open
tstone opened this issue Jan 22, 2012 · 3 comments
Open

Supporting jade includes #45

tstone opened this issue Jan 22, 2012 · 3 comments

Comments

@tstone
Copy link

tstone commented Jan 22, 2012

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

@nrstott
Copy link
Owner

nrstott commented Jan 23, 2012

I'm considering moving the view engine out to its own package as it has little to do with Bogart core. The view engine that is currently in Bogart was intended to provide some level of abstraction to help make it easier to write view engines. I've heard that Jade has moved to a more Django style 'layout' support which would make it not work as well.

I do have a bogart-jade package that works with a now outdated version of Jade.

I think the best solution at the moment will be to move the view engine to its own module, have it provide basically the API it does now which can work with and add layout support to HAML, Mustache, and many other view engines. I will come up with a different recommended solution all together for those who want to use the modern Jade and that solution will be just easy helper functions to render JSGI responses from Jade Templates, in its own package as well.

@tstone
Copy link
Author

tstone commented Jan 23, 2012

What can I do to help or speed that up? Shoot me a github message.

@nrstott
Copy link
Owner

nrstott commented Jan 23, 2012

Github wont let me send you a message. That is greyed out and it says that you haven't provided an email address.
My email / gchat is [email protected].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants