Sinatra-Partial icon indicating copy to clipboard operation
Sinatra-Partial copied to clipboard

Add Feature 'partial-folder'

Open ristrettoblack opened this issue 10 years ago • 3 comments

Specify a Folder-Location for Partials.

# as a config
set :partial_folder, ("partials")

# inline
partial(:news, :partial_folder => 'partials' )

Default is set to false. I hope, i am right.

ristrettoblack avatar Feb 02 '14 14:02 ristrettoblack

Hi @ristrettoblack

Thanks for the contribution. At the moment you could do:

= partial :"partials/news"

but with your suggestion it would be = partial :news because the folder had already been set, is that how you envisage it?

Regards, Iain

yb66 avatar Feb 03 '14 19:02 yb66

Hi @yb66

Thanks for your answer.

Exactly! It's just to keep your Files organized and the Code still clean.

ristrettoblack avatar Feb 03 '14 22:02 ristrettoblack

@ristrettoblack ok, that sounds fine. What it's lacking right now are some specs, and some examples of how it would work in different situations, so let's go through it. For example, if my layout is:

app/
  views/
     layout.haml
     view1.haml
    partials/
        part1.haml
        part2.haml

How could I call partial and override the partial folder setting to get view1.haml to render as a partial? It's my aim to be able to override any of the settings in a local call, hence, all the options.fetch look at a local option before recourse to the settings.

Better to use File.join instead of prepend with the / in the code, as it handles things like double slashes far more effectively.

Iain

yb66 avatar Feb 04 '14 15:02 yb66