Sinatra-Partial
Sinatra-Partial copied to clipboard
Add Feature 'partial-folder'
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.
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
Hi @yb66
Thanks for your answer.
Exactly! It's just to keep your Files organized and the Code still clean.
@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