module Rote::Format::HTML
HTML
Formatting module for Rote
. This module may be mixed in to any Page
instance to provide various HTML
helpers (including those from ERB::Util).
To use this module for a given page, simply place the following code somewhere applicable to that page:
extend Format::HTML
Note that include
cannot be used since the page code is run via instance_eval
.
Public Instance Methods
relative(href)
click to toggle source
Make the given output-root-relative path relative to the current page’s path. This is handy when you do both local preview from some deep directory, and remote deployment to a root
# File lib/rote/format/html.rb 33 def relative(href) 34 thr = href 35 36 if thr.is_a?(String) && href[0,1] == '/' # only interested in absolute 37 dtfn = File.dirname(template_name) + '/' 38 39 count = dtfn == './' ? 0 : dtfn.split('/').length 40 thr = ('../' * count) + href[1..href.length] 41 end 42 43 thr 44 end
Also aliased as: link_rel