Sha256: 1773eda0dcf31dfb8c29a274034565a9910a62527c5b2c6767894344f82c070e
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
require 'rexml/element' module BuildMaster class Link def initialize(site_spec) @site_spec = site_spec end def process(target, template, source) target_path = get_href_as_relative_path(template) result = nil if (target_path == source.path) result = REXML::Element.new('div') result.attributes['class'] = 'current' else result = REXML::Element.new('a') href = target_path.relative_path_from(source.path.parent) result.attributes['href'] = href.to_s end template.attributes.each do |name, value| result.attributes[name] = value unless name == 'href' end template.each_child do |element| runner = TemplateRunner.new(result, template, source) runner.templatelets = @site_spec.load_templatelets runner.process end target.add(result) end private def get_href_as_relative_path(template) href = Pathname.new(template.attribute_value!('href')) if (href.absolute?) href = href.relative_path_from(Pathname.new('/')) end return href end end end
Version data entries
4 entries across 4 versions & 1 rubygems