Codesandbox Liquid tag render to utilize ActionController (#2747) [ci skip]
This commit is contained in:
parent
767029bc10
commit
b6ab47c016
2 changed files with 14 additions and 4 deletions
|
|
@ -1,4 +1,6 @@
|
|||
class CodesandboxTag < LiquidTagBase
|
||||
PARTIAL = "liquids/codesandbox".freeze
|
||||
|
||||
def initialize(tag_name, id, tokens)
|
||||
super
|
||||
@id = parse_id(id)
|
||||
|
|
@ -6,10 +8,13 @@ class CodesandboxTag < LiquidTagBase
|
|||
end
|
||||
|
||||
def render(_context)
|
||||
'<iframe src="https://codesandbox.io/embed/' + @id + @query + '"
|
||||
style="width:100%; height:calc(300px + 8vw); border:0; border-radius: 4px; overflow:hidden;"
|
||||
sandbox="allow-same-origin allow-scripts allow-forms allow-top-navigation-by-user-activation>"
|
||||
</iframe>'
|
||||
ActionController::Base.new.render_to_string(
|
||||
partial: PARTIAL,
|
||||
locals: {
|
||||
id: @id,
|
||||
query: @query
|
||||
},
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
5
app/views/liquids/_codesandbox.html.erb
Normal file
5
app/views/liquids/_codesandbox.html.erb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<iframe
|
||||
src="<%= "https://codesandbox.io/embed/#{id}#{query}" %>"
|
||||
style="width:100%; height:calc(300px + 8vw); border:0; border-radius: 4px; overflow:hidden;"
|
||||
sandbox="allow-same-origin allow-scripts allow-forms allow-top-navigation-by-user-activation>"
|
||||
</iframe>
|
||||
Loading…
Add table
Reference in a new issue