Module: Decidim::NewslettersHelper
- Includes:
- MailerHelper, SanitizeHelper
- Defined in:
- app/helpers/decidim/newsletters_helper.rb
Overview
Helper that provides methods to render links with utm codes, and replaced name
Instance Method Summary collapse
-
#custom_url_for_mail_root(organization, newsletter_id = nil) ⇒ String
this method is used to generate the root link on mail with the utm_codes If the newsletter_id is nil, it returns the root_url.
-
#parse_interpolations(content, user = nil, id = nil) ⇒ String
If the newsletter body there are some links and the Decidim.track_newsletter_links = true it will be replaced with the utm_codes method described below.
Methods included from MailerHelper
Methods included from SanitizeHelper
#decidim_escape_translated, #decidim_html_escape, #decidim_rich_text, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_sanitize_translated, #decidim_url_escape, included
Instance Method Details
#custom_url_for_mail_root(organization, newsletter_id = nil) ⇒ String
this method is used to generate the root link on mail with the utm_codes If the newsletter_id is nil, it returns the root_url
36 37 38 39 40 41 42 43 |
# File 'app/helpers/decidim/newsletters_helper.rb', line 36 def custom_url_for_mail_root(organization, = nil) decidim = EngineRouter.new("decidim", {}) if .present? decidim.root_url(host: organization.host) + utm_codes(organization.host, .to_s) else decidim.root_url(host: organization.host) end end |
#parse_interpolations(content, user = nil, id = nil) ⇒ String
If the newsletter body there are some links and the Decidim.track_newsletter_links = true it will be replaced with the utm_codes method described below. for example transform “es.lipsum.com/” to “es.lipsum.com/?utm_source=localhost&utm_campaign=newsletter_11” And replace “%name” on the subject or content of newsletter to the user Name for example transform “%name” to “User Name”
20 21 22 23 24 25 26 |
# File 'app/helpers/decidim/newsletters_helper.rb', line 20 def parse_interpolations(content, user = nil, id = nil) host = user&.organization&.host&.to_s content = interpret_name(content, user) content = (content, id, host) decidim_transform_image_urls(content, host) end |