marnen / middleman-breadcrumbs

Breadcrumbs helper for Middleman (http://www.middlemanapp.com)
MIT License
11 stars 12 forks source link

Passing options to the config.rb file? #8

Closed jasonmelgoza closed 8 years ago

jasonmelgoza commented 8 years ago

@marnen Is it possible to define the :separator in a sites config file?

marnen commented 8 years ago

No—I didn't think of doing that. Pull requests welcome!

marnen commented 8 years ago

Actually...wait, you could do it manually, by simply calling the breadcrumbs helper with separator: config[:separator] or something. At least I think you could; does Middleman complain if you use set with an unexpected property name in the config file? (I've never tried to do that, and am not at my personal computer right now to check.)

jasonmelgoza commented 8 years ago

@marnen That's the stuff! Got this working locally like so.

# Breadcrumb separator template
@separator_template = " / "

# Activate middleman-breadcrumb gem
activate :breadcrumbs
set :separator, @separator_template

Then in our .slim template I did this.

p = breadcrumbs(current_page.parent, separator: config[:separator])
marnen commented 8 years ago

Great. But there's no need to use an @instance variable -- a local variable, or just a plain string literal, would do.

I'll probably make this a config setting at some point -- you're right that it should be one.

marnen commented 8 years ago

Oh, also, you should normally call breadcrumbs with current_page as the first argument. Is there some reason you're using a different value?

jasonmelgoza commented 8 years ago

Don't know. A team-mate implemented the plugin before I jumped in. I'll give those suggestions a shot though. Cheers!! 🍻

marnen commented 8 years ago

Reopening: I should still make this a real config option and have it pick up the default from there.

marnen commented 8 years ago

Working on this.

marnen commented 8 years ago

@jasonmelgoza Implemented in 0.4.0. Try it and see what you think—instructions are in the README.