Skip to content

Commit

Permalink
Merge pull request #2781 from AlchemyCMS/backport/7.0-stable/pr-2779
Browse files Browse the repository at this point in the history
[7.0-stable] Mark ingredient output as html_safe
  • Loading branch information
tvdeyen committed Mar 8, 2024
2 parents f208a3b + 279a33b commit c4f47b6
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/audio_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class AudioView < BaseView
def call
content_tag(:audio, **html_options) do
tag(:source, src: src, type: type)
end
end.html_safe
end

def render?
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/base_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(ingredient, html_options: {})
end

def call
value
value.html_safe
end

def render?
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/boolean_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Alchemy
module Ingredients
class BooleanView < BaseView
def call
Alchemy.t(value, scope: "ingredient_values.boolean")
Alchemy.t(value, scope: "ingredient_values.boolean").html_safe
end

def render?
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/datetime_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def call
ingredient.value.to_s(:rfc822)
else
::I18n.l(ingredient.value, format: date_format)
end
end.html_safe
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/file_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def call
class: ingredient.css_class.presence,
title: ingredient.title.presence
}.merge(html_options)
)
).html_safe
end

def render?
Expand Down
23 changes: 16 additions & 7 deletions app/components/alchemy/ingredients/headline_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ def initialize(ingredient, level: nil, html_options: {})
end

def call
content_tag "h#{@level || ingredient.level}",
ingredient.value,
id: ingredient.dom_id.presence,
class: [
ingredient.size ? "h#{ingredient.size}" : nil,
html_options[:class]
]
content_tag tag_name, id: dom_id, class: css_classes do
ingredient.value
end.html_safe
end

private

def tag_name = "h#{@level || ingredient.level}"

def dom_id = ingredient.dom_id.presence

def css_classes
[
ingredient.size ? "h#{ingredient.size}" : nil,
html_options[:class]
]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/link_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(ingredient, text: nil, html_options: {})
end

def call
link_to(link_text, value, {target: link_target}.merge(html_options))
link_to(link_text, value, {target: link_target}.merge(html_options)).html_safe
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/page_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class PageView < BaseView
delegate :page, to: :ingredient

def call
link_to page.name, alchemy.show_page_path(urlname: page.urlname)
link_to(page.name, alchemy.show_page_path(urlname: page.urlname)).html_safe
end

def render?
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/picture_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def call
content_tag(:figure, output, {class: ingredient.css_class.presence}.merge(html_options))
else
output
end
end.html_safe
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/richtext_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def call
ingredient.stripped_body
else
value.to_s.html_safe
end
end.html_safe
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/text_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def call
target: ((link_target == "blank") ? "_blank" : nil),
data: {link_target: link_target}
}.merge(html_options))
end
end.html_safe
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/video_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class VideoView < BaseView
def call
content_tag(:video, html_options) do
tag(:source, src: src, type: attachment.file_mime_type)
end
end.html_safe
end

def render?
Expand Down

0 comments on commit c4f47b6

Please sign in to comment.