Utilize ERB template in CodepenTag (#2748) [ci skip]
This commit is contained in:
parent
b645942dd2
commit
86d8128dd9
3 changed files with 20 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
8
app/views/liquids/_codepen.html.erb
Normal file
8
app/views/liquids/_codepen.html.erb
Normal 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>
|
||||
|
|
@ -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&default-tab=result&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&default-tab=result&embed-version=2" scrolling="no" frameborder="no" allowtransparency="true" style="width: 100%;">
|
||||
</iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue