Module: Plate::URLHelper
- Included in:
- View
- Defined in:
- lib/plate/helpers/url_helper.rb
Overview
Includes basic helpers for managing URLs within your site.
Instance Method Summary collapse
-
#absolutize_paths(content) ⇒ Object
(also: #a)
replace all relative links within the given content block to absolute links containing the base url for this site.
-
#sanitize_slug(str) ⇒ Object
(also: #s)
Cleans up a string to make it URl-friendly, removing all special characters, spaces, and sanitizing to a dashed, lowercase string.
Instance Method Details
#absolutize_paths(content) ⇒ Object Also known as: a
replace all relative links within the given content block to absolute links containing the base url for this site.
This is useful in creating RSS and/or Atom feeds that you’d like to contain links back to your site.
href or src values that don’t start with a slash are left intact.
18 19 20 |
# File 'lib/plate/helpers/url_helper.rb', line 18 def absolutize_paths(content) content.gsub(Regexp.new("(src|href)=(\"|')/"), "\\1=\\2#{site.url}/") end |
#sanitize_slug(str) ⇒ Object Also known as: s
Cleans up a string to make it URl-friendly, removing all special characters, spaces, and sanitizing to a dashed, lowercase string.
25 26 27 |
# File 'lib/plate/helpers/url_helper.rb', line 25 def sanitize_slug(str) self.site.sanitize_slug(str) end |