octopress-return-tag 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10cefa9470c98abea2956978236688791dc045d4
4
+ data.tar.gz: 0ed20c4dc24ae437a993665b1245efced0129480
5
+ SHA512:
6
+ metadata.gz: 5f27a948903bbfa7ad5a61c8fe58bfe0282b267f1f39f764a859846ad7206a3dabc1ab78fb8bb68b27574dc40a2221a740fca800bd3d0a96183d4e198e60a880
7
+ data.tar.gz: 0484f64eec45134d5bf46bd4a921a0bb7f64d15f750368cade31c1cf3104f2e02d774fa7aedc034b4cbc13eb3c2ef407854eaed334836c7954f46201093f9bac
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,67 @@
1
+ # Octopress Return Tag
2
+
3
+ Render Liquid variables with conditions and filters.
4
+
5
+ [![Build Status](https://travis-ci.org/octopress/return-tag.svg)](https://travis-ci.org/octopress/return-tag)
6
+ [![Gem Version](http://img.shields.io/gem/v/octopress-return-tag.svg)](https://rubygems.org/gems/octopress-return-tag)
7
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://octopress.mit-license.org)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'octopress-return-tag'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install octopress-return-tag
22
+
23
+ Next add it to your gems list in Jekyll's `_config.yml`
24
+
25
+ gems:
26
+ - octopress-return-tag
27
+
28
+ ## Usage
29
+
30
+ Here's a simple example where you can see that it does the same thing as the standard liquid render braces.
31
+
32
+ {{ site.author }} //=> Bobby Tables
33
+ {% return site.author %} //=> Bobby Tables
34
+
35
+ {{ site.author | upcase }} //=> BOBBY TABLES
36
+ {% return site.author | upcase %} //=> BOBBY TABLES
37
+
38
+ Conditional returns.
39
+
40
+ {% return "→ " if linkpost %}
41
+ {% return "★ " unless linkpost %}
42
+ {% return post.external-url || post.url %}
43
+ {% return (post ? post.date : page.date ) | datetime | date_to_xmlschema %}
44
+
45
+ Why is this useful? Here's how you might add title markers for a linkpost blog.
46
+
47
+ {% return (linkpost ? "→ " : "★ ") %}{{ post.title }}
48
+
49
+ Now here's what you'd have to do with standard liquid tags:
50
+
51
+ {% if linkpost %}
52
+ {% capture title %}→ {{ post.title}}{% endcapture %}
53
+ {% else %}
54
+ {% capture title %}★ {{ post.title }}{% endcapture %}
55
+ {% endif %}
56
+ {{ title }}
57
+
58
+ See how `if` and `capture` make it harder to read a template file? That's why the return tag exists.
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it ( https://github.com/octopress/return-tag/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create a new Pull Request
67
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ require "octopress-return-tag/version"
2
+ require "octopress-tag-helpers"
3
+ require "jekyll"
4
+
5
+ module Octopress
6
+ module Tags
7
+ module ReturnTag
8
+ class Tag < Liquid::Tag
9
+ def initialize(tag_name, markup, tokens)
10
+ @markup = markup.strip
11
+ super
12
+ end
13
+
14
+ def render(context)
15
+ return unless markup = TagHelpers::Conditional.parse(@markup, context)
16
+
17
+ TagHelpers::Var.get_value(markup, context)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ Liquid::Template.register_tag('return', Octopress::Tags::ReturnTag::Tag)
@@ -0,0 +1,7 @@
1
+ module Octopress
2
+ module Tags
3
+ module ReturnTag
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-return-tag/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "octopress-return-tag"
8
+ spec.version = Octopress::Tags::ReturnTag::VERSION
9
+ spec.authors = ["Brandon Mathis"]
10
+ spec.email = ["brandon@imathis.com"]
11
+ spec.summary = %q{Return tag renders a variable with some nice features}
12
+ spec.description = %q{Return tag renders a variable with some nice features}
13
+ spec.homepage = "https://github.com/octopress/return-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"
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-return-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-return-tag
@@ -0,0 +1,23 @@
1
+
2
+
3
+ ## Simple return
4
+ bar → bar
5
+
6
+ ## Conditional return
7
+ bar → bar
8
+ '' → ''
9
+
10
+ ## Ternary return
11
+ nope → nope
12
+
13
+ ## Cascading return
14
+ nope → nope
15
+ bar → bar
16
+
17
+ ## Test local variables
18
+ yep → yep
19
+
20
+ ## Returns with filters
21
+ 2013-07-21T18:59:00-05:00 → 2013-07-21T18:59:00-05:00
22
+ 2013-07-21T18:59:00-05:00 → 2013-07-21T18:59:00-05:00
23
+
data/test/index.html ADDED
@@ -0,0 +1,30 @@
1
+ ---
2
+ layout: nil
3
+ date: 2013-07-21 18:59
4
+ people:
5
+ - { name: Bill }
6
+ - { name: Bob }
7
+ ---
8
+ {% assign foo = 'bar' %}
9
+
10
+ ## Simple return
11
+ bar → {% return foo %}
12
+
13
+ ## Conditional return
14
+ bar → {% return foo if foo %}
15
+ '' → '{% return foo unless foo == 'bar' %}'
16
+
17
+ ## Ternary return
18
+ nope → {% return (foo == 'baz' ? foo : 'nope') %}
19
+
20
+ ## Cascading return
21
+ nope → {% return bingo || fez || 'nope' %}
22
+ bar → {% return bingo || fez || foo %}
23
+
24
+ ## Test local variables
25
+ yep → {% for person in page.people %}{% return 'yep' if person.name == 'Bill' %}{% endfor %}
26
+
27
+ ## Returns with filters
28
+ 2013-07-21T18:59:00-05:00 → {% return post.date or page.date | datetime | date_to_xmlschema %}
29
+ 2013-07-21T18:59:00-05:00 → {% return (false ? post.date : page.date) | datetime | date_to_xmlschema %}
30
+
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octopress-return-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: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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: Return tag renders a variable with some nice features
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-return-tag.rb
97
+ - lib/octopress-return-tag/version.rb
98
+ - octopress-return-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/return-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: Return tag renders a variable with some nice features
128
+ test_files:
129
+ - test/.clash.yml
130
+ - test/Gemfile
131
+ - test/_config.yml
132
+ - test/_expected/index.html
133
+ - test/index.html