diff --git a/app/liquid_tags/instagram_tag.rb b/app/liquid_tags/instagram_tag.rb index b19382d6e..695b8ca7c 100644 --- a/app/liquid_tags/instagram_tag.rb +++ b/app/liquid_tags/instagram_tag.rb @@ -1,24 +1,18 @@ class InstagramTag < LiquidTagBase + PARTIAL = "liquids/instagram".freeze + def initialize(tag_name, id, tokens) super @id = parse_id(id) end def render(_context) - html = <<-HTML -
- - -
- HTML - finalize_html(html) + ActionController::Base.new.render_to_string( + partial: PARTIAL, + locals: { + id: @id + }, + ) end private diff --git a/app/views/liquids/_instagram.html.erb b/app/views/liquids/_instagram.html.erb new file mode 100644 index 000000000..f5a45a74d --- /dev/null +++ b/app/views/liquids/_instagram.html.erb @@ -0,0 +1,11 @@ +
+ + +
diff --git a/spec/liquid_tags/instagram_tag_spec.rb b/spec/liquid_tags/instagram_tag_spec.rb index d2559ea3a..1fe15bbb3 100644 --- a/spec/liquid_tags/instagram_tag_spec.rb +++ b/spec/liquid_tags/instagram_tag_spec.rb @@ -12,8 +12,9 @@ RSpec.describe InstagramTag, type: :liquid_template do it "checks that the tag is properly parsed" do valid_id = "BXgGcAUjM39" - html = "
" # rubocop:disable Metrics/LineLength - expect(generate_instagram_tag(valid_id).render).to eq(html.chomp("\n")) + liquid = generate_instagram_tag(valid_id) + rendered_instagram = liquid.render + Approvals.verify(rendered_instagram, name: "instagram_liquid_tag", format: :html) end it "rejects invalid ids" do diff --git a/spec/support/fixtures/approvals/instagram_liquid_tag.approved.html b/spec/support/fixtures/approvals/instagram_liquid_tag.approved.html new file mode 100644 index 000000000..8417871dd --- /dev/null +++ b/spec/support/fixtures/approvals/instagram_liquid_tag.approved.html @@ -0,0 +1,9 @@ + + + +
+ +
+ +