Utilize ERB template in SoundcloudTag (#2752) [ci skip]

This commit is contained in:
Mario See 2019-05-09 16:17:03 -04:00 committed by Mac Siri
parent 995d4eb1e2
commit e0d4329089
3 changed files with 19 additions and 14 deletions

View file

@ -1,23 +1,19 @@
class SoundcloudTag < LiquidTagBase
PARTIAL = "liquids/soundcloud".freeze
def initialize(tag_name, link, tokens)
super
@link = parse_link(link)
@height = 166
end
def render(_context)
# src = build_src
html = <<-HTML
<iframe
width="100%"
height="#{@height}"
scrolling="no"
frameborder="no"
allow="autoplay"
src="https://w.soundcloud.com/player/?url=#{@link}&auto_play=false&color=%23000000&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true">
</iframe>
HTML
finalize_html(html)
ActionController::Base.new.render_to_string(
partial: PARTIAL,
locals: {
link: @link,
height: 166
},
)
end
private

View file

@ -0,0 +1,8 @@
<iframe
width="100%"
height="<%= height %>"
scrolling="no"
frameborder="no"
allow="autoplay"
src="https://w.soundcloud.com/player/?url=<%= link %>&auto_play=false&color=%23000000&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true" >
</iframe>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<iframe width="100%" height="166" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/user-261265215/dev-to-review-episode-2&amp;auto_play=false&amp;color=%23000000&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;show_teaser=true"> </iframe>
<iframe width="100%" height="166" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/user-261265215/dev-to-review-episode-2&amp;auto_play=false&amp;color=%23000000&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;show_teaser=true">
</iframe>
</body>
</html>