Sha256: 1f359c732e5d81d02bbd9aecd93ed851b3cd8742d5ec15df202c80099fe6eb82
Contents?: true
Size: 884 Bytes
Versions: 2
Compression:
Stored size: 884 Bytes
Contents
$:.unshift(File.join('..', File.dirname(__FILE__))) require 'uri' require 'template_error' require 'template_runner' module BuildMaster class Href def initialize(site_spec) @site_spec = site_spec end def process(target, template, source) url = template.attribute_value!('url') href = construct_href(url, source.path) target.attributes[name_based_on_target(target)] = href end private def construct_href(url, current_path) href = url if (URI.parse(url).scheme.nil?) path = Pathname.new(url) if (not path.relative?) path = path.relative_path_from(Pathname.new('/')) end href = path.relative_path_from(current_path.parent) end return href end def name_based_on_target(target) name = target.name if (name == 'img') return 'src' else return 'href' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
BuildMaster-0.9.0 | lib/buildmaster/templatelets/href.rb |
BuildMaster-0.9.1 | lib/buildmaster/templatelets/href.rb |