diff --git a/app/components/alchemy/ingredients/headline_view.rb b/app/components/alchemy/ingredients/headline_view.rb index 9d579ffab9..2f76e98e10 100644 --- a/app/components/alchemy/ingredients/headline_view.rb +++ b/app/components/alchemy/ingredients/headline_view.rb @@ -1,8 +1,13 @@ module Alchemy module Ingredients class HeadlineView < BaseView + def initialize(ingredient, level: nil, html_options: {}) + super(ingredient, html_options: html_options) + @level = level + end + def call - content_tag "h#{ingredient.level}", + content_tag "h#{@level || ingredient.level}", ingredient.value, id: ingredient.dom_id.presence, class: [ diff --git a/app/helpers/alchemy/elements_helper.rb b/app/helpers/alchemy/elements_helper.rb index 8c1963887d..355626d6c3 100644 --- a/app/helpers/alchemy/elements_helper.rb +++ b/app/helpers/alchemy/elements_helper.rb @@ -210,20 +210,5 @@ def element_tags_attributes(element, options = {}) {"data-element-tags" => options[:formatter].call(element.tag_list)} end - - def ingredient_view_deprecation_notice(ingredient, file) - Alchemy::Deprecation.warn(<<~WARN) - rendering `alchemy/ingredients/#{file.split("/").last.sub(/^_/, "")}` partial is deprecated. - - Please render the view component directly instead: - - <%= render ingredient.as_view_component %> - - or use the `el.render` helper inside a `element_view_for` helper: - - <%= el.render(:#{ingredient.role}) %> - - WARN - end end end diff --git a/app/views/alchemy/ingredients/_audio_view.html.erb b/app/views/alchemy/ingredients/_audio_view.html.erb index 04bc895971..d40520d624 100644 --- a/app/views/alchemy/ingredients/_audio_view.html.erb +++ b/app/views/alchemy/ingredients/_audio_view.html.erb @@ -1,2 +1 @@ -<%- ingredient_view_deprecation_notice(audio_view, __FILE__) -%> <%= render audio_view.as_view_component -%> diff --git a/app/views/alchemy/ingredients/_boolean_view.html.erb b/app/views/alchemy/ingredients/_boolean_view.html.erb index 33070d3040..fef4714673 100644 --- a/app/views/alchemy/ingredients/_boolean_view.html.erb +++ b/app/views/alchemy/ingredients/_boolean_view.html.erb @@ -1,2 +1 @@ -<%- ingredient_view_deprecation_notice(boolean_view, __FILE__) -%> <%= render boolean_view.as_view_component -%> diff --git a/app/views/alchemy/ingredients/_datetime_view.html.erb b/app/views/alchemy/ingredients/_datetime_view.html.erb index e6fe5a6407..4e5701f43f 100644 --- a/app/views/alchemy/ingredients/_datetime_view.html.erb +++ b/app/views/alchemy/ingredients/_datetime_view.html.erb @@ -1,4 +1,3 @@ -<%- ingredient_view_deprecation_notice(datetime_view, __FILE__) -%> <%= render datetime_view.as_view_component( **local_assigns.slice(:options) ) -%> diff --git a/app/views/alchemy/ingredients/_file_view.html.erb b/app/views/alchemy/ingredients/_file_view.html.erb index 30b73f33ea..40ba7b293a 100644 --- a/app/views/alchemy/ingredients/_file_view.html.erb +++ b/app/views/alchemy/ingredients/_file_view.html.erb @@ -1,4 +1,3 @@ -<%- ingredient_view_deprecation_notice(file_view, __FILE__) -%> <%= render file_view.as_view_component( **local_assigns.slice(:options), **local_assigns.slice(:html_options) diff --git a/app/views/alchemy/ingredients/_headline_view.html.erb b/app/views/alchemy/ingredients/_headline_view.html.erb index 95294922a2..de093cf0e1 100644 --- a/app/views/alchemy/ingredients/_headline_view.html.erb +++ b/app/views/alchemy/ingredients/_headline_view.html.erb @@ -1,4 +1,3 @@ -<%- ingredient_view_deprecation_notice(headline_view, __FILE__) -%> <%= render headline_view.as_view_component( **local_assigns.slice(:options), **local_assigns.slice(:html_options) diff --git a/app/views/alchemy/ingredients/_html_view.html.erb b/app/views/alchemy/ingredients/_html_view.html.erb index 524433b1cd..9fdffe18b0 100644 --- a/app/views/alchemy/ingredients/_html_view.html.erb +++ b/app/views/alchemy/ingredients/_html_view.html.erb @@ -1,2 +1 @@ -<%- ingredient_view_deprecation_notice(html_view, __FILE__) -%> <%= render html_view.as_view_component -%> diff --git a/app/views/alchemy/ingredients/_link_view.html.erb b/app/views/alchemy/ingredients/_link_view.html.erb index b1465de67f..e8de6c62c1 100644 --- a/app/views/alchemy/ingredients/_link_view.html.erb +++ b/app/views/alchemy/ingredients/_link_view.html.erb @@ -1,4 +1,3 @@ -<%- ingredient_view_deprecation_notice(link_view, __FILE__) -%> <%= render link_view.as_view_component( **local_assigns.slice(:options), **local_assigns.slice(:html_options) diff --git a/app/views/alchemy/ingredients/_node_view.html.erb b/app/views/alchemy/ingredients/_node_view.html.erb index 8b92ded1a1..ffb6d1dad5 100644 --- a/app/views/alchemy/ingredients/_node_view.html.erb +++ b/app/views/alchemy/ingredients/_node_view.html.erb @@ -1,2 +1 @@ -<%- ingredient_view_deprecation_notice(node_view, __FILE__) -%> <%= render node_view.as_view_component -%> diff --git a/app/views/alchemy/ingredients/_page_view.html.erb b/app/views/alchemy/ingredients/_page_view.html.erb index 52c5be81bb..af57ee185c 100644 --- a/app/views/alchemy/ingredients/_page_view.html.erb +++ b/app/views/alchemy/ingredients/_page_view.html.erb @@ -1,2 +1 @@ -<%- ingredient_view_deprecation_notice(page_view, __FILE__) -%> <%= render page_view.as_view_component -%> diff --git a/app/views/alchemy/ingredients/_picture_view.html.erb b/app/views/alchemy/ingredients/_picture_view.html.erb index a003b42236..ddb1221d76 100644 --- a/app/views/alchemy/ingredients/_picture_view.html.erb +++ b/app/views/alchemy/ingredients/_picture_view.html.erb @@ -1,4 +1,3 @@ -<%- ingredient_view_deprecation_notice(picture_view, __FILE__) -%> <%= render picture_view.as_view_component( **local_assigns.slice(:options), **local_assigns.slice(:html_options) diff --git a/app/views/alchemy/ingredients/_richtext_view.html.erb b/app/views/alchemy/ingredients/_richtext_view.html.erb index 254eec3b00..6049505e10 100644 --- a/app/views/alchemy/ingredients/_richtext_view.html.erb +++ b/app/views/alchemy/ingredients/_richtext_view.html.erb @@ -1,4 +1,3 @@ -<%- ingredient_view_deprecation_notice(richtext_view, __FILE__) -%> <%= render richtext_view.as_view_component( **local_assigns.slice(:options) ) -%> diff --git a/app/views/alchemy/ingredients/_select_view.html.erb b/app/views/alchemy/ingredients/_select_view.html.erb index 6e3eb51365..f2a2bb6f97 100644 --- a/app/views/alchemy/ingredients/_select_view.html.erb +++ b/app/views/alchemy/ingredients/_select_view.html.erb @@ -1,2 +1 @@ -<%- ingredient_view_deprecation_notice(select_view, __FILE__) -%> <%= render select_view.as_view_component -%> diff --git a/app/views/alchemy/ingredients/_text_view.html.erb b/app/views/alchemy/ingredients/_text_view.html.erb index e120c10f95..d2f345f96c 100644 --- a/app/views/alchemy/ingredients/_text_view.html.erb +++ b/app/views/alchemy/ingredients/_text_view.html.erb @@ -1,4 +1,3 @@ -<%- ingredient_view_deprecation_notice(text_view, __FILE__) -%> <%= render text_view.as_view_component( **local_assigns.slice(:options), **local_assigns.slice(:html_options) diff --git a/app/views/alchemy/ingredients/_video_view.html.erb b/app/views/alchemy/ingredients/_video_view.html.erb index f644f905b8..6c43508f9a 100644 --- a/app/views/alchemy/ingredients/_video_view.html.erb +++ b/app/views/alchemy/ingredients/_video_view.html.erb @@ -1,2 +1 @@ -<%- ingredient_view_deprecation_notice(video_view, __FILE__) -%> <%= render video_view.as_view_component -%> diff --git a/spec/views/alchemy/ingredients/headline_view_spec.rb b/spec/views/alchemy/ingredients/headline_view_spec.rb index ee6f787253..180dc88be6 100644 --- a/spec/views/alchemy/ingredients/headline_view_spec.rb +++ b/spec/views/alchemy/ingredients/headline_view_spec.rb @@ -11,6 +11,14 @@ expect(rendered).to have_content("Hello") end + context "with level option passed" do + it "renders headline for given level" do + render(ingredient, options: {level: 1}) + expect(rendered).to have_selector("h1") + expect(rendered).to have_content("Hello") + end + end + context "with dom_id" do it "adds id" do render ingredient