IJSDK-32 "Copy link to source to clipboard" button

This commit is contained in:
kisenka 2015-06-02 13:02:35 +03:00
parent 702d7f3c2b
commit b6d18f2bba

20
_plugins/copy_area.rb Normal file
View File

@ -0,0 +1,20 @@
class CopyToClipboard < Liquid::Tag
def initialize(tagName, markup, tokens)
super
@text = markup
end
def render(context)
text = @text.strip.gsub(/^'|"/, '').gsub(/'|"$/, '')
<<-HTML
<div class="copy-area">
<input class="copy-area__field" value="#{text}">
<button class="btn copy-area__button" data-clipboard-text="#{text}">Copy</button>
</div>
HTML
end
Liquid::Template.register_tag "copyArea", self
end