Is there a way to retain an HTTP GET parameter in Sinatra without manually writing them in the links?
I've got a simple sinatra webpage, with multiple color schemes. To change a color scheme i simply use a simple get parameter in the following way:
before do
color = params[:color]
if color == 'blue'
@color = :blue
elsif color == 'pink'
@color = :pink
else
@color = :orange
end
end
But when the user clicks a link on the website, the color parameter (of course) disappears. Is there a way of keeping the color parameter without doing the followin开发者_高级运维g? (In haml):
%a{:href => "/?color=#{@color.to_s}"} Home
You could define a new HAML helper (like in that repository) and use it in your template like any other helpers. I think it is the most convenient way to achieve that.
精彩评论