octopress-capture-tag 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: afd953d69e1d4274498834bfba91075210a3940f
4
+ data.tar.gz: 646c647ba45a2c0b0175c1a565852f5e721c1067
5
+ SHA512:
6
+ metadata.gz: 5426335414c110dd88de1a6cfc74fea0965990671e7856f5fb994d68a495d0a1cf334f92b9f835aba37876d2720c112967194b5620d585dd08dfbe01eda50b2c
7
+ data.tar.gz: ea5de6bf3c1dc59d09a862e454b9864b15588900500a0b752b713032b08d7e0cafedcb266e7104cb8fa2e3c04d53bd992fe9f77bf55cb4cb3579bb07643b8bbf
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ _site
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ script: cd test && bundle exec clash
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in octopress_render_tag.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Brandon Mathis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Octopress Capture Tag
2
+
3
+ A more powerful capture liquid tag. Features:
4
+
5
+ - Conditional capture
6
+ - Support additive assignment with `+=` operator
7
+
8
+ [![Build Status](https://travis-ci.org/octopress/capture-tag.svg)](https://travis-ci.org/octopress/capture-tag)
9
+ [![Gem Version](http://img.shields.io/gem/v/octopress-capture-tag.svg)](https://rubygems.org/gems/octopress-capture-tag)
10
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://octopress.mit-license.org)
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'octopress-capture-tag'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install octopress-capture-tag
25
+
26
+ Next add it to your gems list in Jekyll's `_config.yml`
27
+
28
+ gems:
29
+ - octopress-capture-tag
30
+
31
+ ## Usage
32
+
33
+ Use the capture tag like normal.
34
+
35
+ {% capture var1 %}
36
+ awesome
37
+ {% endcapture %}
38
+
39
+ {{ var1 }} //=> awesome
40
+
41
+ Filter captured content.
42
+
43
+ {% capture var1 | upcase %}
44
+ awesome
45
+ {% endcapture %}
46
+
47
+ {{ var1 }} //=> AWESOME
48
+
49
+ Append to variables with capture.
50
+
51
+ // Assuming var1 == 'awesome'
52
+ {% capture var1 += %}
53
+ sauce
54
+ {% endcapture %}
55
+
56
+ {{ var1 }} //=> awesome sauce
57
+
58
+ Note: the `+=` operator will act as a normal capture if the
59
+ capture variable is `nil`.
60
+
61
+ Conditionally capture.
62
+
63
+ {% capture greeting if true %}
64
+ Hi Guys
65
+ {% endcapture %}
66
+
67
+ {% capture greeting unless false %}
68
+ Hi Guys
69
+ {% endcapture %}
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it ( https://github.com/octopress/capture-tag/fork )
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,43 @@
1
+ require "octopress-capture-tag/version"
2
+ require "octopress-tag-helpers"
3
+ require "jekyll"
4
+
5
+ module Octopress
6
+ module Tags
7
+ module CaptureTag
8
+ class Tag < Liquid::Block
9
+ SYNTAX = /([[:word:]]+)\s*(\+=|\|\|=)?/o
10
+
11
+ def initialize(tag_name, markup, tokens)
12
+ @markup = markup
13
+ super
14
+ end
15
+
16
+ def render(context)
17
+ return unless markup = TagHelpers::Conditional.parse(@markup, context)
18
+ if markup =~ TagHelpers::Var::HAS_FILTERS
19
+ markup = $1
20
+ filters = $2
21
+ end
22
+
23
+ if markup =~ SYNTAX
24
+ var = $1
25
+ operator = $2
26
+ value = super.lstrip
27
+
28
+ unless value.nil? || filters.nil?
29
+ value = TagHelpers::Var.render_filters(value, filters, context)
30
+ end
31
+
32
+ context = TagHelpers::Var.set_var(var, operator, value, context)
33
+ else
34
+ raise SyntaxError.new("Syntax Error in 'capture' - Valid syntax: capture [var]")
35
+ end
36
+ ''
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ Liquid::Template.register_tag('capture', Octopress::Tags::CaptureTag::Tag)
@@ -0,0 +1,7 @@
1
+ module Octopress
2
+ module Tags
3
+ module CaptureTag
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'octopress-capture-tag/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "octopress-capture-tag"
8
+ spec.version = Octopress::Tags::CaptureTag::VERSION
9
+ spec.authors = ["Brandon Mathis"]
10
+ spec.email = ["brandon@imathis.com"]
11
+ spec.summary = %q{A powerful replacement for the Liquid capture tag}
12
+ spec.description = %q{A powerful replacement for the Liquid capture tag}
13
+ spec.homepage = "https://github.com/octopress/capture-tag"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "octopress-tag-helpers", "~> 1.0"
22
+ spec.add_runtime_dependency "jekyll", "~> 2.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "clash"
27
+ end
data/test/.clash.yml ADDED
@@ -0,0 +1,2 @@
1
+ build: true
2
+ compare: _expected _site
data/test/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'octopress-capture-tag', path: '../'
4
+ gem 'pry-debugger'
5
+ gem 'clash'
data/test/_config.yml ADDED
@@ -0,0 +1,13 @@
1
+ # Site settings
2
+ title: Your awesome title
3
+ email: your-email@domain.com
4
+ baseurl: ""
5
+ url: "http://yourdomain.com"
6
+
7
+ exclude:
8
+ - Gemfile*
9
+
10
+ # Build settings
11
+ markdown: kramdown
12
+ gems:
13
+ - octopress-capture-tag
@@ -0,0 +1,22 @@
1
+
2
+ ## Simple capture
3
+ hi → hi
4
+
5
+ ## Conditional capture
6
+ '' → ''
7
+ hi → hi
8
+ '' → ''
9
+ hi → hi
10
+ hi → hi
11
+
12
+ ## Additive capture
13
+ hihi → hihi
14
+
15
+ ## Complex capture
16
+ hi → hi
17
+ um, hi → um, hi
18
+
19
+
20
+ ## Test filters
21
+ FOO BAR BAZ BOOGA → FOO BAR BAZ BOOGA
22
+
data/test/index.html ADDED
@@ -0,0 +1,27 @@
1
+ ---
2
+ layout: nil
3
+ ---
4
+ {% assign some_bool = false %}
5
+ ## Simple capture
6
+ hi → {% capture var1 %}hi{% endcapture %}{{ var1 }}
7
+
8
+ ## Conditional capture
9
+ '' → '{% capture var2 unless true %}hi{% endcapture %}{{ var2 }}'
10
+ hi → {% capture var3 if true %}hi{% endcapture %}{{ var3 }}
11
+ '' → '{% capture var4 if some_bool %}hi{% endcapture %}{{ var4 }}'
12
+ hi → {% capture var3 ||= %}nooooo{% endcapture %}{{ var3 }}
13
+ hi → {% capture varz ||= %}hi{% endcapture %}{{ varz }}
14
+
15
+ ## Additive capture
16
+ hihi → {% capture var3 += if true %}hi{% endcapture %}{{ var3 }}
17
+
18
+ ## Complex capture
19
+ hi → {% capture var8 if false or page.layout %}hi{% endcapture %}{{ var8 }}
20
+ um, hi → {% capture var9 if false or page.layout %}
21
+ {% assign var10 = 'hi' %}
22
+ um, {{ var10 }}
23
+ {% endcapture %}{{ var9 }}
24
+
25
+ ## Test filters
26
+ FOO BAR BAZ BOOGA → {% capture filters | upcase %} foo bar baz booga {% endcapture %}{{ filters }}
27
+
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octopress-capture-tag
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Mathis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octopress-tag-helpers
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jekyll
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: clash
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A powerful replacement for the Liquid capture tag
84
+ email:
85
+ - brandon@imathis.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/octopress-capture-tag.rb
97
+ - lib/octopress-capture-tag/version.rb
98
+ - octopress-capture-tag.gemspec
99
+ - test/.clash.yml
100
+ - test/Gemfile
101
+ - test/_config.yml
102
+ - test/_expected/index.html
103
+ - test/index.html
104
+ homepage: https://github.com/octopress/capture-tag
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.2.2
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: A powerful replacement for the Liquid capture tag
128
+ test_files:
129
+ - test/.clash.yml
130
+ - test/Gemfile
131
+ - test/_config.yml
132
+ - test/_expected/index.html
133
+ - test/index.html