markdown_form 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b7214f247099396c45a06e38c5566e216923315bd53aeabadb341fe5cfcad50
4
- data.tar.gz: '08139144260bd100687f870f71d2d674d7189109660539d6513fa42df19b8bad'
3
+ metadata.gz: f90b79df2d27e2df7010278e064350e72d4cb4d2a25bdfed96f9f3393a66aa9a
4
+ data.tar.gz: 4586e549bb883e06a80d033ec6af6e347a01ce8af09da293d4338e86e95e79dc
5
5
  SHA512:
6
- metadata.gz: 036e7cb2c4f91c5861420f8034fb3b72f8dfc267ffb57efe7c33fe01bdb14a4e1025e5654b4fc2fa61ddab4d7eb2b0ab633f4d4449a3375d69e4d7a39156982c
7
- data.tar.gz: 812f16617339515ddc82137af049fe3fa1f0cbffaab9e9d00477b1503a61f8be86672768195a07c0746b7a7cad23e5e84d3de46f7adedb8392f99be9fb15ffa1
6
+ metadata.gz: d81aa8ccbc2315818fabd07c65cefd7f3939dee04c96cffebddf4d3b32aaad7eed08543e674c322c95ae16f877dacc281ced2725228a95d4d41c07c02d295af1
7
+ data.tar.gz: 922eb581f5c4964ac4f3affa30e1ed851816ee1fd6109d825001a66bb5eea6f38178c8f3aef895dd5a15a7acfb268c3a0723107c37abab2205efe516e213c55d
data/README.md CHANGED
@@ -7,33 +7,25 @@ destination, and (if applicable) any JavaScript for handling submissions.
7
7
 
8
8
  ## Installation
9
9
 
10
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
11
-
12
10
  Install the gem and add to the application's Gemfile by executing:
13
11
 
14
12
  ```bash
15
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
13
+ bundle add markdown_form
16
14
  ```
17
15
 
18
16
  If bundler is not being used to manage dependencies, install the gem by executing:
19
17
 
20
18
  ```bash
21
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
19
+ gem install markdown_form
22
20
  ```
23
21
 
24
22
  ## Usage
25
23
 
26
- TODO: Write usage instructions here
27
-
28
- ## Development
29
-
30
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
-
32
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
24
+ TODO: Write usage instructions here once I figure out exactly how the syntax is going to be designed.
33
25
 
34
26
  ## Contributing
35
27
 
36
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/markdown_form.
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rosuav/markdown_form.
37
29
 
38
30
  ## License
39
31
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MarkdownForm
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/markdown_form.rb CHANGED
@@ -2,7 +2,32 @@
2
2
 
3
3
  require_relative "markdown_form/version"
4
4
 
5
- module MarkdownForm
6
- class Error < StandardError; end
7
- # Your code goes here...
5
+ module Jekyll
6
+ class MarkdownFormTag < Liquid::Tag
7
+
8
+ def initialize(tag_name, text, tokens)
9
+ super
10
+ text.strip!
11
+ if m = text.match(/^([A-Za-z0-9]+)(\??): (.*)$/)
12
+ @name = m[1]
13
+ @type = m[2] == "?" ? "checkbox" : "text"
14
+ @label = m[3]
15
+ else
16
+ @name = text.downcase
17
+ @type = "text"
18
+ @label = text
19
+ end
20
+ if @name == "submit" then @type = "submit" end
21
+ end
22
+
23
+ def render(context)
24
+ case @type
25
+ when "checkbox" then "<label><input type=checkbox name=#{@name}> #{@label}"
26
+ when "submit" then "<button type=submit>#{@label}</button>"
27
+ else "<label>#{@label}: <input name=#{@name}></label>"
28
+ end
29
+ end
30
+ end
8
31
  end
32
+
33
+ Liquid::Template.register_tag('form', Jekyll::MarkdownFormTag)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Angelico