class Twigg::App::Server
Public Instance Methods
active?(*paths_or_regex)
click to toggle source
Returns a truthy value (the “active” class) if the current request corresponds to any path in `paths_or_regex`; otherwise, returns `nil`.
@param paths_or_regex May be a String, Array of Strings, or a Regexp.
# File lib/twigg-app/app/server.rb, line 63 def active?(*paths_or_regex) case paths_or_regex when Array, String Array(paths_or_regex).include?(request.path_info) when Regexp paths_or_regex.match(request.path_info) end && 'active' end
day_links()
click to toggle source
# File lib/twigg-app/app/server.rb, line 72 def day_links { class: 'day-links glyphicon glyphicon-time', data: { toggle: 'popover', content: haml(:'/shared/day_links') }, title: 'Other time intervals', } end
find_template(views, name, engine, &block)
click to toggle source
Support multiple view directories.
See: github.com/sinatra/sinatra/commit/441b17ead90d3e3a90a3a4
Calls superclass method
# File lib/twigg-app/app/server.rb, line 51 def find_template(views, name, engine, &block) Array(views).each { |v| super(v, name, engine, &block) } end
h(str)
click to toggle source
# File lib/twigg-app/app/server.rb, line 55 def h(str) Rack::Utils.escape_html(str) end
name_to_id(name)
click to toggle source
# File lib/twigg-app/app/server.rb, line 85 def name_to_id(name) name.tr(' .@', '-').downcase end
random_quip()
click to toggle source
# File lib/twigg-app/app/server.rb, line 93 def random_quip Quips.random end
slug_to_name(slug)
click to toggle source
# File lib/twigg-app/app/server.rb, line 89 def slug_to_name(slug) slug.tr('.', ' ') end