Class: SimpleNavigation::Adapters::Nanoc Deprecated

Inherits:
Base
  • Object
show all
Defined in:
lib/simple_navigation/adapters/nanoc.rb

Overview

Deprecated.

This adapter is for Nanoc3 (circa 2011-2012) and is no longer actively maintained. Nanoc3 is obsolete and has been replaced by Nanoc 4+. This adapter is kept for backward compatibility but should not be used for new projects.

Instance Attribute Summary

Attributes inherited from Base

#context, #request

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#request_path, #request_uri

Constructor Details

#initialize(ctx) ⇒ Nanoc

rubocop:disable Lint/MissingSuper



16
17
18
# File 'lib/simple_navigation/adapters/nanoc.rb', line 16

def initialize(ctx) # rubocop:disable Lint/MissingSuper
  @context = ctx
end

Class Method Details

.register(root) ⇒ Object



10
11
12
13
# File 'lib/simple_navigation/adapters/nanoc.rb', line 10

def register(root)
  SimpleNavigation.set_env(root, 'development')
  Nanoc3::Context.include SimpleNavigation::Helpers
end

Instance Method Details

#content_tag(type, content, options = {}) ⇒ Object

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



40
41
42
# File 'lib/simple_navigation/adapters/nanoc.rb', line 40

def (type, content, options = {})
  "<#{type} #{to_attributes(options)}>#{content}</#{type}>"
end

#context_for_evalObject

Returns the context in which the config files will be evaluated



21
22
23
# File 'lib/simple_navigation/adapters/nanoc.rb', line 21

def context_for_eval
  context
end

#current_page?(url) ⇒ Boolean

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

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/simple_navigation/adapters/nanoc.rb', line 27

def current_page?(url)
  path = context.item.path
  path && path.chop == url
end

Returns a link with the specified name, url and options. Used for rendering.



34
35
36
# File 'lib/simple_navigation/adapters/nanoc.rb', line 34

def link_to(name, url, options = {})
  "<a href='#{url}' #{to_attributes(options)}>#{name}</a>"
end