Sha256: 70b4bdfdeaca69a5cf3eb8a3e41e9de6a267474bd44f744f0f0d0336c0edcd9e
Contents?: true
Size: 939 Bytes
Versions: 3
Compression:
Stored size: 939 Bytes
Contents
module Cadmus module Tags class PageUrl < ::Liquid::Tag class << self attr_reader :page_path_method def define_page_path_method(&page_path_method) @page_path_method = page_path_method end end attr_reader :page_name def initialize(tag_name, args, tokens) super @page_name = args.strip end 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.message end end end end end Liquid::Template.register_tag('page_url', Cadmus::Tags::PageUrl)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cadmus-0.7.1 | lib/cadmus/tags.rb |
cadmus-0.7.0 | lib/cadmus/tags.rb |
cadmus-0.6.0 | lib/cadmus/tags.rb |