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 +4 -4
- data/README.md +4 -12
- data/lib/markdown_form/version.rb +1 -1
- data/lib/markdown_form.rb +28 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f90b79df2d27e2df7010278e064350e72d4cb4d2a25bdfed96f9f3393a66aa9a
|
|
4
|
+
data.tar.gz: 4586e549bb883e06a80d033ec6af6e347a01ce8af09da293d4338e86e95e79dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
|
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/
|
|
28
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rosuav/markdown_form.
|
|
37
29
|
|
|
38
30
|
## License
|
|
39
31
|
|
data/lib/markdown_form.rb
CHANGED
|
@@ -2,7 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "markdown_form/version"
|
|
4
4
|
|
|
5
|
-
module
|
|
6
|
-
class
|
|
7
|
-
|
|
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)
|