Class: Nanoc::Filters::RelativizePaths Private
- Inherits:
-
Nanoc::Filter
- Object
- Nanoc::Filters::RelativizePaths
- Includes:
- MemoWise, Helpers::LinkTo
- Defined in:
- lib/nanoc/filters/relativize_paths.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- SELECTORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ '*/@href', '*/@src', 'object/@data', 'video/@poster', 'param[@name="movie"]/@value', 'form/@action', 'comment()', { path: '*/@srcset', type: :srcset }, ].freeze
- GCSE_SEARCH_WORKAROUND =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'nanoc__gcse_search__f7ac3462f628a053f86fe6563c0ec98f1fe45cee'
Instance Method Summary collapse
-
#run(content, params = {}) ⇒ String
private
Relativizes all paths in the given content, which can be HTML, XHTML, XML or CSS.
Methods included from Helpers::LinkTo
#link_to, #link_to_unless_current, #relative_path_to
Methods included from Helpers::HTMLEscape
Methods included from Helpers::Capturing
Instance Method Details
#run(content, params = {}) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Relativizes all paths in the given content, which can be HTML, XHTML, XML or CSS. This filter is quite useful if a site needs to be hosted in a subdirectory instead of a subdomain. In HTML, all ‘href` and `src` attributes will be relativized. In CSS, all `url()` references will be relativized.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/nanoc/filters/relativize_paths.rb', line 47 def run(content, params = {}) # Set assigns so helper function can be used @item_rep = assigns[:item_rep] if @item_rep.nil? # Filter case params[:type] when :css relativize_css(content, params) when :html, :html5, :xml, :xhtml relativize_html_like(content, params) else raise 'The relativize_paths needs to know the type of content to ' \ 'process. Pass a :type to the filter call (:html for HTML, ' \ ':xhtml for XHTML, :xml for XML, or :css for CSS).' end end |