diff --git a/app/liquid_tags/gist_tag.rb b/app/liquid_tags/gist_tag.rb index ca0acb35d..21ad34eeb 100644 --- a/app/liquid_tags/gist_tag.rb +++ b/app/liquid_tags/gist_tag.rb @@ -1,16 +1,18 @@ class GistTag < LiquidTagBase + PARTIAL = "liquids/gist".freeze + def initialize(tag_name, link, tokens) super @uri = build_uri(link) end def render(_context) - html = <<~HTML -
- -
- HTML - finalize_html(html) + ActionController::Base.new.render_to_string( + partial: PARTIAL, + locals: { + uri: @uri + }, + ) end def self.special_script diff --git a/app/views/liquids/_gist.html.erb b/app/views/liquids/_gist.html.erb new file mode 100644 index 000000000..c437d5258 --- /dev/null +++ b/app/views/liquids/_gist.html.erb @@ -0,0 +1,3 @@ +
+ +
diff --git a/spec/liquid_tags/gist_tag_spec.rb b/spec/liquid_tags/gist_tag_spec.rb index 2f14435ac..7e1364729 100644 --- a/spec/liquid_tags/gist_tag_spec.rb +++ b/spec/liquid_tags/gist_tag_spec.rb @@ -40,14 +40,14 @@ RSpec.describe GistTag, type: :liquid_template do it "accepts proper gist url" do gist_links.each do |link| liquid = generate_new_liquid(link) - expect(liquid.render.delete(" ")).to eq(generate_script(link)) + expect(liquid.render.tr("\n", " ").delete(" ")).to eq(generate_script(link)) end end it "handles 'file' option" do liquid = generate_new_liquid(link_with_file_option) link, option = link_with_file_option.split(" ", 2) - expect(liquid.render.delete(" ")).to eq(generate_script(link, option)) + expect(liquid.render.tr("\n", " ").delete(" ")).to eq(generate_script(link, option)) end it "rejects invalid gist url" do