shortcode 0.1.1 → 0.1.2
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.
- data/.gitignore +1 -0
- data/.travis.yml +24 -0
- data/Appraisals +15 -0
- data/Gemfile +2 -0
- data/README.md +5 -3
- data/Rakefile +2 -0
- data/gemfiles/rails_3.0.gemfile +8 -0
- data/gemfiles/rails_3.1.gemfile +8 -0
- data/gemfiles/rails_3.2.gemfile +8 -0
- data/gemfiles/rails_4.0.gemfile +8 -0
- data/lib/shortcode.rb +4 -3
- data/lib/shortcode/configuration.rb +7 -4
- data/lib/shortcode/version.rb +1 -1
- data/shortcode.gemspec +0 -1
- metadata +8 -18
data/.gitignore
CHANGED
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- 2.0.0
|
6
|
+
- 2.1.0
|
7
|
+
- ruby-head
|
8
|
+
- jruby-19mode
|
9
|
+
- jruby-head
|
10
|
+
script: bundle exec rspec
|
11
|
+
|
12
|
+
matrix:
|
13
|
+
allow_failures:
|
14
|
+
- rvm: ruby-head
|
15
|
+
- rvm: jruby-head
|
16
|
+
exclude:
|
17
|
+
- rvm: 1.9.2
|
18
|
+
gemfile: gemfiles/rails_4.0.gemfile
|
19
|
+
|
20
|
+
gemfile:
|
21
|
+
- gemfiles/rails_3.0.gemfile
|
22
|
+
- gemfiles/rails_3.1.gemfile
|
23
|
+
- gemfiles/rails_3.2.gemfile
|
24
|
+
- gemfiles/rails_4.0.gemfile
|
data/Appraisals
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Shortcode
|
2
2
|
|
3
|
+
[](https://travis-ci.org/kernow/shortcode)
|
4
|
+
|
3
5
|
A ruby gem for parsing Wordpress style shortcodes. The gem uses a [PEG](http://en.wikipedia.org/wiki/Parsing_expression_grammar) (Parsing Expression Grammar) parser rather than using regular expressions so its easier to understand, test and extend.
|
4
6
|
|
5
7
|
## Installation
|
@@ -99,7 +101,7 @@ Sometimes the data passed to the template from the shortcode it not enough. Lets
|
|
99
101
|
In a rails app you could return image records to the template using something like this:
|
100
102
|
|
101
103
|
```ruby
|
102
|
-
class
|
104
|
+
class CustomPresenter
|
103
105
|
|
104
106
|
def self.for
|
105
107
|
:quote
|
@@ -121,7 +123,7 @@ class CustomPrsenter
|
|
121
123
|
private
|
122
124
|
|
123
125
|
def images
|
124
|
-
|
126
|
+
Image.where("id IN (?)", @attributes[:ids])
|
125
127
|
end
|
126
128
|
end
|
127
129
|
```
|
@@ -131,7 +133,7 @@ end
|
|
131
133
|
To register a presenter simply call `Shortcode.register_presenter` passing the presenter class e.g.
|
132
134
|
|
133
135
|
```ruby
|
134
|
-
Shortcode.register_presenter(
|
136
|
+
Shortcode.register_presenter(CustomPresenter)
|
135
137
|
```
|
136
138
|
|
137
139
|
## Contributing
|
data/Rakefile
CHANGED
data/lib/shortcode.rb
CHANGED
@@ -6,8 +6,7 @@ module Shortcode
|
|
6
6
|
extend self
|
7
7
|
|
8
8
|
attr_accessor :configuration, :presenters
|
9
|
-
|
10
|
-
|
9
|
+
self.presenters = {}
|
11
10
|
|
12
11
|
def setup
|
13
12
|
self.configuration ||= Configuration.new
|
@@ -41,4 +40,6 @@ require 'shortcode/presenter'
|
|
41
40
|
require 'shortcode/transformer'
|
42
41
|
require 'shortcode/tag'
|
43
42
|
require 'shortcode/exceptions'
|
44
|
-
require 'shortcode/railtie' if defined?(Rails)
|
43
|
+
require 'shortcode/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
|
44
|
+
|
45
|
+
Shortcode.setup {}
|
@@ -1,17 +1,20 @@
|
|
1
1
|
class Shortcode::Configuration
|
2
2
|
# Sets the template parser to use, supports :erb and :haml, default is :haml
|
3
3
|
attr_accessor :template_parser
|
4
|
-
@template_parser = :haml
|
5
4
|
|
6
5
|
# Sets the template parser to use, supports :erb and :haml, default is :haml
|
7
6
|
attr_accessor :template_path
|
8
|
-
@template_path = "app/views/shortcode_templates"
|
9
7
|
|
10
8
|
# Set the supported block_tags
|
11
9
|
attr_accessor :block_tags
|
12
|
-
@block_tags = [:quote]
|
13
10
|
|
14
11
|
# Set the supported self_closing_tags
|
15
12
|
attr_accessor :self_closing_tags
|
16
|
-
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@template_parser = :haml
|
16
|
+
@template_path = "app/views/shortcode_templates"
|
17
|
+
@block_tags = []
|
18
|
+
@self_closing_tags = []
|
19
|
+
end
|
17
20
|
end
|
data/lib/shortcode/version.rb
CHANGED
data/shortcode.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shortcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|
@@ -91,22 +91,6 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: rails
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '4'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '4'
|
110
94
|
description: Gem for parsing wordpress style shortcodes
|
111
95
|
email:
|
112
96
|
- jamie@kernowsoul.com
|
@@ -116,10 +100,16 @@ extra_rdoc_files: []
|
|
116
100
|
files:
|
117
101
|
- .gitignore
|
118
102
|
- .rbenv-version
|
103
|
+
- .travis.yml
|
104
|
+
- Appraisals
|
119
105
|
- Gemfile
|
120
106
|
- LICENSE.txt
|
121
107
|
- README.md
|
122
108
|
- Rakefile
|
109
|
+
- gemfiles/rails_3.0.gemfile
|
110
|
+
- gemfiles/rails_3.1.gemfile
|
111
|
+
- gemfiles/rails_3.2.gemfile
|
112
|
+
- gemfiles/rails_4.0.gemfile
|
123
113
|
- lib/shortcode.rb
|
124
114
|
- lib/shortcode/configuration.rb
|
125
115
|
- lib/shortcode/exceptions.rb
|