Utilize ERB template in CodepenTag (#2748) [ci skip]

This commit is contained in:
Mario See 2019-05-09 19:33:59 -04:00 committed by Mac Siri
parent b645942dd2
commit 86d8128dd9
3 changed files with 20 additions and 12 deletions

View file

@ -1,22 +1,21 @@
class CodepenTag < LiquidTagBase
PARTIAL = "liquids/codepen".freeze
def initialize(tag_name, link, tokens)
super
@link = parse_link(link)
@build_options = parse_options(link)
@height = 600
end
def render(_context)
html = <<-HTML
<iframe height="#{@height}"
src="#{@link}?height=#{@height}&#{@build_options}&embed-version=2"
scrolling="no"
frameborder="no"
allowtransparency="true"
style="width: 100%;">
</iframe>
HTML
finalize_html(html)
ActionController::Base.new.render_to_string(
partial: PARTIAL,
locals: {
link: @link,
height: 600,
build_options: @build_options
},
)
end
private

View file

@ -0,0 +1,8 @@
<iframe
height="<%= height %>"
src="<%= link %>?height=<%= height %>&<%= build_options %>&embed-version=2"
scrolling="no"
frameborder="no"
allowtransparency="true"
style="width: 100%;">
</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 height="600" src="https://codepen.io/twhite96/embed/XKqrJX?height=600&amp;default-tab=result&amp;embed-version=2" scrolling="no" frameborder="no" allowtransparency="true" style="width: 100%;"> </iframe>
<iframe height="600" src="https://codepen.io/twhite96/embed/XKqrJX?height=600&amp;default-tab=result&amp;embed-version=2" scrolling="no" frameborder="no" allowtransparency="true" style="width: 100%;">
</iframe>
</body>
</html>