Utilize ERB template in SoundcloudTag (#2752) [ci skip]
This commit is contained in:
parent
995d4eb1e2
commit
e0d4329089
3 changed files with 19 additions and 14 deletions
|
|
@ -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
|
||||
|
|
|
|||
8
app/views/liquids/_soundcloud.html.erb
Normal file
8
app/views/liquids/_soundcloud.html.erb
Normal 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>
|
||||
|
|
@ -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&auto_play=false&color=%23000000&hide_related=false&show_comments=true&show_user=true&show_reposts=false&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&auto_play=false&color=%23000000&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true">
|
||||
</iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue