-
-
Save stefanosc/7510871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sinatra environment | |
# Make sure that the link to the "bootstrap.min.js" file is correct in your layout.erb (shown below): | |
<script src="/vendor/bootstrap/js/bootstrap.min.js"></script> | |
# Put this in your .erb | |
<%= show_env %> | |
# Place constant inside of your main.rb | |
SHOW_ENVIRONMENT = true | |
# Method to be placed inside of the "helpers" method | |
def show_env | |
if SHOW_ENVIRONMENT | |
string = "<div class=\"dropdown\">" | |
string << "<a class=\"btn dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">Click to see environment details <span class=\"caret\"></span></a>" | |
string << "<ul id=\"menu1\" class=\"dropdown-menu\" role=\"menu\" aria-labelledby=\"dLabel\">" | |
env.each do |k, v| | |
f v.is_a?(Hash) | |
v.each do |l, m| | |
unless m.is_a?(Array) | |
string << "<li role=\"presentation\" id=\"dLabel\">#{l}: #{m}</li>" | |
else | |
string << "<li>#{l}:</li>" | |
string << "<ul>" | |
m.each do |p| | |
string << "<li>#{p}</li>" | |
end | |
string << "</ul>" | |
end | |
end | |
else | |
string << "<li>#{k}: #{v}</li>" | |
end | |
end | |
string << "</ul></div>" | |
return string | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment