Sha256: 900787c1d5e8d59293eeac8a31fb8febeaecf74f2ba5c646f3eda1e3d90a57f7
Contents?: true
Size: 746 Bytes
Versions: 7
Compression:
Stored size: 746 Bytes
Contents
class SimpleContentManagement::SimpleMenu::Builder def initialize(context) @context = context end def item(name, uri, options = {}) @context.content_tag :li, @context.link_to(name, uri, options), uri_equivalency(uri) ? { class: "active" } : {} end def yield "".html_safe.tap do |out| SimpleContentManagement::SimpleMenuItem.ordered.each do |menu_item| out << item(menu_item.name, menu_item.uri, menu_item.is_target_blank ? { target: "_blank" } : {}) end end end private def uri_equivalency(uri) request_uri = URI.parse @context.request.original_url target_uri = URI.parse uri (target_uri.host.nil? || target_uri.host == request_uri.host) && (target_uri.path.nil? || target_uri.path == request_uri.path) end end
Version data entries
7 entries across 7 versions & 1 rubygems