lib/wikilink/converter/namespace.rb in wikilink-converter-0.1.0 vs lib/wikilink/converter/namespace.rb in wikilink-converter-0.2.1

- old
+ new

@@ -3,10 +3,11 @@ module Wikilink class Converter # Namespace converter class Namespace include LinkHelper + include HTMLAttributes DEFAULT_NAME = '' attr_reader :options @@ -17,42 +18,38 @@ def config(&block) @block = block self end - def run(colon, path, name, current_page) + def run(run_options) if @block - instance_exec(colon, path, name, current_page, &@block) + instance_exec(run_options, &@block) end end class Default < Namespace - def run(colon, path, name, current_page) + def run(run_options) return super if @block + path = run_options[:path].to_s path, fragment = path.split('#', 2) path, query = path.split('?', 2) fragment = '#' + fragment if fragment query = '?' + query if query url = to_url(path, fragment, query) - link_to(name, url, :class => html_class) + link_to(run_options[:name], url, :class => html_class(run_options[:class])) end def to_url(path, fragment, query) if path.nil? || path.empty? [query, fragment].join else [options[:prefix], path, options[:suffix], query, fragment].join end end - end - - protected - def html_class - [options[:class], ('external' if options[:external])] end end end end