Class: Formspree
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Formspree
- Defined in:
- lib/jekyll-formspree.rb
Instance Method Summary collapse
-
#initialize(tagName, content, tokens) ⇒ Formspree
constructor
A new instance of Formspree.
- #render(context) ⇒ Object
Constructor Details
#initialize(tagName, content, tokens) ⇒ Formspree
Returns a new instance of Formspree.
4 5 6 7 |
# File 'lib/jekyll-formspree.rb', line 4 def initialize(tagName, content, tokens) super @content = content end |
Instance Method Details
#render(context) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jekyll-formspree.rb', line 9 def render(context) @formspree_id = "#{context[@content.strip]}" site = context.registers[:site] tmpl_path = File.join site.in_source_dir(site.config["includes_dir"].to_s), "formspree.html" if File.exist?(tmpl_path) tmpl = File.read tmpl_path tmpl = (Liquid::Template.parse tmpl).render site.site_payload.merge!({"formspree_id" => @formspree_id}) else %Q{<style>.form-container { max-width: 100%; } .form-container input { position: relative; top: 0; left: 0; width: 100%; height: 20px; padding: 0 ; } .form-container textarea { position: relative; top: 0; left: 0; width: 100%; height: 80px; padding: 0; } </style> <form action="https://formspree.io/#{ @formspree_id }" method="POST" class='form-container'> <label>Your email:</label><br /><input type="text" name="_replyto" /> <label>Your message:</label><br /><textarea name="message"></textarea> <button type="submit">Send</button> </form>} end end |