class SimpleNavigation::Adapters::Nanoc

Public Class Methods

new(ctx) click to toggle source
# File lib/simple_navigation/adapters/nanoc.rb, line 11
def initialize(ctx)
  @context = ctx
end
register(root) click to toggle source
# File lib/simple_navigation/adapters/nanoc.rb, line 5
def register(root)
  SimpleNavigation.set_env(root, 'development')
  Nanoc3::Context.send(:include, SimpleNavigation::Helpers)
end

Public Instance Methods

content_tag(type, content, options={}) click to toggle source

Returns a tag of the specified type, content and options. Used for rendering.

# File lib/simple_navigation/adapters/nanoc.rb, line 35
def content_tag(type, content, options={})
  "<#{type} #{to_attributes(options)}>#{content}</#{type}>"
end
context_for_eval() click to toggle source

Returns the context in which the config files will be evaluated

# File lib/simple_navigation/adapters/nanoc.rb, line 16
def context_for_eval
  context
end
current_page?(url) click to toggle source

Returns true if the current request's url matches the specified url. Used to determine if an item should be autohighlighted.

# File lib/simple_navigation/adapters/nanoc.rb, line 22
def current_page?(url)
  path = context.item.path
  path && path.chop == url
end

Private Instance Methods

to_attributes(options) click to toggle source
# File lib/simple_navigation/adapters/nanoc.rb, line 40
def to_attributes(options)
  options.map {|k, v| v.nil? ? nil : "#{k}='#{v}'"}.compact.join(' ')
end