monokrome / jaded-brunch

Jade for brunch, supporting both dynamic and static loading jade.
MIT License
23 stars 10 forks source link

Added support for options.locals #11

Closed itzaks closed 9 years ago

itzaks commented 10 years ago

Previously there was no possible way of passing locals from config.plugins.jaded to the template rendering. This commit adds support for config.plugins.jaded.locals object passed to each template file.

monokrome commented 10 years ago

@itzaks Thanks for the pull request. I will look over it tonight! I was thinking that this would work by providing locals as options when compiling the template as passed via @jadeOptions. Did you try this?

module.exports.config =
    plugins:
        jaded:
            jade:
                locals:
                    site: 'monokro.me' 

NOTE: The extra jade sublevel is optional, but can be used to give exact options. Without it, jaded will try to use it's own options but pick only ones that aren't jaded-specific.

If you did try this and it doesn't work then the other concern here is that locals would presumably need to somehow be available in the browser as well, so we may need to export wrapped template functions (or an additional file) to provide that. This could get messy, though.

monokrome commented 9 years ago

I'm merging this, but would still be interested in a response from @itzaks. Let me know if you tested that. I'll deploy a new release tonight.

itzaks commented 9 years ago

Hey! Sorry for not giving a response, seems like I missed that. Okay, cool :) Hm, as far as I remember I tested that without luck.