Class: Cadmus::Tags::PageUrl
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Cadmus::Tags::PageUrl
- Defined in:
- lib/cadmus/tags.rb
Class Attribute Summary collapse
-
.page_path_method ⇒ Object
readonly
Returns the value of attribute page_path_method.
Instance Attribute Summary collapse
-
#page_name ⇒ Object
readonly
Returns the value of attribute page_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tag_name, args, tokens) ⇒ PageUrl
constructor
A new instance of PageUrl.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, args, tokens) ⇒ PageUrl
Returns a new instance of PageUrl.
14 15 16 17 |
# File 'lib/cadmus/tags.rb', line 14 def initialize(tag_name, args, tokens) super @page_name = args.strip end |
Class Attribute Details
.page_path_method ⇒ Object (readonly)
Returns the value of attribute page_path_method.
5 6 7 |
# File 'lib/cadmus/tags.rb', line 5 def page_path_method @page_path_method end |
Instance Attribute Details
#page_name ⇒ Object (readonly)
Returns the value of attribute page_name.
12 13 14 |
# File 'lib/cadmus/tags.rb', line 12 def page_name @page_name end |
Class Method Details
.define_page_path_method(&page_path_method) ⇒ Object
7 8 9 |
# File 'lib/cadmus/tags.rb', line 7 def define_page_path_method(&page_path_method) @page_path_method = page_path_method end |
Instance Method Details
#render(context) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cadmus/tags.rb', line 19 def render(context) unless self.class.page_path_method return "Error: #{self.class.name}.page_path_method is not defined. Please call #{self.class.name}.define_page_path_method in an initializer." end begin parent = context.registers['parent'] Rails.application.routes.url_helpers.instance_exec(page_name, parent, &self.class.page_path_method) rescue Exception => e e. end end |