Class: SimpleNavigation::Adapters::Nanoc
- Defined in:
- lib/simple_navigation/adapters/nanoc.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#content_tag(type, content, options = {}) ⇒ Object
Returns a tag of the specified type, content and options.
-
#context_for_eval ⇒ Object
Returns the context in which the config files will be evaluated.
-
#current_page?(url) ⇒ Boolean
Returns true if the current request’s url matches the specified url.
-
#initialize(ctx) ⇒ Nanoc
constructor
A new instance of Nanoc.
-
#link_to(name, url, options = {}) ⇒ Object
Returns a link with the specified name, url and options.
Methods inherited from Base
Constructor Details
#initialize(ctx) ⇒ Nanoc
Returns a new instance of Nanoc.
11 12 13 |
# File 'lib/simple_navigation/adapters/nanoc.rb', line 11 def initialize(ctx) @context = ctx end |
Class Method Details
.register(root) ⇒ Object
5 6 7 8 |
# File 'lib/simple_navigation/adapters/nanoc.rb', line 5 def register(root) SimpleNavigation.set_env(root, 'development') Nanoc3::Context.send(: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.
35 36 37 |
# File 'lib/simple_navigation/adapters/nanoc.rb', line 35 def content_tag(type, content, = {}) "<#{type} #{to_attributes()}>#{content}</#{type}>" end |
#context_for_eval ⇒ Object
Returns the context in which the config files will be evaluated
16 17 18 |
# File 'lib/simple_navigation/adapters/nanoc.rb', line 16 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.
22 23 24 25 |
# File 'lib/simple_navigation/adapters/nanoc.rb', line 22 def current_page?(url) path = context.item.path path && path.chop == url end |
#link_to(name, url, options = {}) ⇒ Object
Returns a link with the specified name, url and options. Used for rendering.
29 30 31 |
# File 'lib/simple_navigation/adapters/nanoc.rb', line 29 def link_to(name, url, = {}) "<a href='#{url}' #{to_attributes()}>#{name}</a>" end |