Sha256: f2ab318e615c31cb21fa5a3081360635f51dcfe5943e6aaa4c9b2c077b3399a3

Contents?: true

Size: 1.25 KB

Versions: 56

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

# Alchemy url helpers
#
# This helper is included within alchemy/pages_helper
#
module Alchemy
  module UrlHelper
    # Returns the path for rendering an alchemy page
    def show_alchemy_page_path(page, optional_params = {})
      alchemy.show_page_path(show_page_path_params(page, optional_params))
    end

    # Returns the url for rendering an alchemy page
    def show_alchemy_page_url(page, optional_params = {})
      alchemy.show_page_url(show_page_path_params(page, optional_params))
    end

    # Returns the correct params-hash for passing to show_page_path
    def show_page_path_params(page, optional_params = {})
      raise ArgumentError, "Page is nil" if page.nil?

      url_params = {urlname: page.urlname}.update(optional_params)
      prefix_locale?(page.language_code) ? url_params.update(locale: page.language_code) : url_params
    end

    # Returns the path for downloading an alchemy attachment
    def download_alchemy_attachment_path(attachment)
      alchemy.download_attachment_path(attachment, attachment.slug)
    end

    # Returns the url for downloading an alchemy attachment
    def download_alchemy_attachment_url(attachment)
      alchemy.download_attachment_url(attachment, attachment.slug)
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
alchemy_cms-7.4.2 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.3.6 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.2.9 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.4.1 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.4.0 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.3.5 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.2.8 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.1.13 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.0.16 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.3.4 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.3.3 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.3.2 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.2.7 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.3.1 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.3.0 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.2.6 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.2.5 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.1.12 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.0.15 app/helpers/alchemy/url_helper.rb
alchemy_cms-7.2.4 app/helpers/alchemy/url_helper.rb