I use Liquid with Sinatra and want to make a specific value ( Sinatra::Application.environmentin particular) available in all templates, without defining it as local in every get / post. For instance:
In app.rb (my main application file):
get '/some/route' do
liquid :my_template
end
In app.rb, my main application file or something that I can require / include:
some_awesome_technique do
def app_env
Sinatra::Application.environment
end
end
In any template:
<p>
{% if environment == :development %}
Never see this in production
{% end %}
</p>
<p>
{% if dev_mode %}
Or this...
{% endif %}
</p>
I really don't need an implementation unless I need to add redundant code to each route. Thanks in advance!
source
share