octopress-assign-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: 62469a436958d256362c662fa056029e8c88d620
4
+ data.tar.gz: edb1c18e288cbd124790e33bc5fe46d6a7e33b2f
5
+ SHA512:
6
+ metadata.gz: 2a1de155ef971e9a83e234a2aed656b390fc0259e2b8756850eb4d30a520d7e62beb31dcfae74e7f70515c70e3da96af087b1aa61a422e48ce13875fbe023758
7
+ data.tar.gz: a7b60d00a6255151ebc56a72df460af45340a1c0816832b7f250b52240a5c2f2af89537d4338fd31757b0e88348ed6535b3205fa01e81bde9c372c88258e1645
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,57 @@
1
+ # Octopress Assign Tag
2
+
3
+ A more powerful assign liquid tag. Features:
4
+
5
+ - Conditional assignment
6
+ - Ternary assignment
7
+ - Support for `||`, `||=` and `+=`
8
+
9
+ [![Build Status](https://travis-ci.org/octopress/assign-tag.svg)](https://travis-ci.org/octopress/assign-tag)
10
+ [![Gem Version](http://img.shields.io/gem/v/octopress-assign-tag.svg)](https://rubygems.org/gems/octopress-assign-tag)
11
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://octopress.mit-license.org)
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ gem 'octopress-assign-tag'
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install octopress-assign-tag
26
+
27
+ Next add it to your gems list in Jekyll's `_config.yml`
28
+
29
+ gems:
30
+ - octopress-assign-tag
31
+
32
+ ## Usage
33
+
34
+ Use the assign tag like normal.
35
+
36
+ {% assign var1 = 'awesome' %} //=> 'awesome'
37
+ {% assign var2 = var1 | upcase %} //=> 'AWESOME'
38
+
39
+ Conditionally assign variables.
40
+
41
+ {% assign linkpost = true if post.external-url %}
42
+ {% assign comments = true unless post.comments == false %}
43
+ {% assign url (post ? post.url : page.url) %}
44
+
45
+ Use fancy operators in assignment.
46
+
47
+ {% assign author = post.author || page.author || site.author %}
48
+ {% assign name ||= site.name %}
49
+ {% assign title_text += ' →' if linkpost %}
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it ( https://github.com/octopress/assign-tag/fork )
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,38 @@
1
+ require "octopress-assign-tag/version"
2
+ require "octopress-tag-helpers"
3
+ require "jekyll"
4
+
5
+ module Octopress
6
+ module Tags
7
+ module AssignTag
8
+ class Tag < Liquid::Tag
9
+ SYNTAX = /([[:word:]]+)\s*(=|\+=|\|\|=)\s*(.*)\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
+
19
+ if markup =~ SYNTAX
20
+ var = $1
21
+ operator = $2
22
+ value = $3
23
+
24
+ value = TagHelpers::Var.get_value(value, context)
25
+ return if value.nil?
26
+
27
+ context = TagHelpers::Var.set_var(var, operator, value, context)
28
+ else
29
+ raise SyntaxError.new("Syntax Error in 'assign tag': #{@markup} - Valid syntax: assign [var] = [source] | filter")
30
+ end
31
+ ''
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ Liquid::Template.register_tag('assign', Octopress::Tags::AssignTag::Tag)
@@ -0,0 +1,7 @@
1
+ module Octopress
2
+ module Tags
3
+ module AssignTag
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-assign-tag/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "octopress-assign-tag"
8
+ spec.version = Octopress::Tags::AssignTag::VERSION
9
+ spec.authors = ["Brandon Mathis"]
10
+ spec.email = ["brandon@imathis.com"]
11
+ spec.summary = %q{A powerful replacement for the Liquid assign tag}
12
+ spec.description = %q{A powerful replacement for the Liquid assign tag}
13
+ spec.homepage = "https://github.com/octopress/assign-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-assign-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-assign-tag
@@ -0,0 +1,23 @@
1
+ ## Simple assign
2
+ yep → yep
3
+ yep → yep
4
+
5
+ ## Conditional assign
6
+ '' → ''
7
+ nope → nope
8
+ nope → nope
9
+ yep → yep
10
+
11
+ ## Cascading assign
12
+ nope → nope
13
+ foo → foo
14
+ '' → ''
15
+
16
+ ## Additive assign
17
+ yepyep → yepyep
18
+
19
+ ## Complex assignment
20
+ awesome → awesome
21
+ AWESOME → AWESOME
22
+ whatever-man → whatever-man
23
+
data/test/index.html ADDED
@@ -0,0 +1,26 @@
1
+ ---
2
+ layout: nil
3
+ ---
4
+ ## Simple assign
5
+ yep → {% assign var1 = 'yep' %}{{ var1 }}
6
+ yep → {% assign var2 = 'yep' %}{{ var2 }}
7
+
8
+ ## Conditional assign
9
+ '' → '{% assign var3 = 'yep' unless true %}{{ var3 }}'
10
+ nope → {% assign var4 = 'nope' if true %}{{ var4 }}
11
+ nope → {% assign var4 ||= 'yep' %}{{ var4 }}
12
+ yep → {% assign varz ||= 'yep' %}{{ varz }}
13
+
14
+ ## Cascading assign
15
+ nope → {% assign var6 = baz || var4 %}{{ var6 }}
16
+ foo → {% assign var7 = baz || 'foo' %}{{ var7 }}
17
+ '' → '{% assign var8 = baz || foo || nil %}{{ var8 }}'
18
+
19
+ ## Additive assign
20
+ yepyep → {% assign var1 += 'yep' %}{{ var1 }}
21
+
22
+ ## Complex assignment
23
+ awesome → {% assign var9 = (page.layout == 'nil' ? 'awesome' : 'lame' ) %}{{ var9 }}
24
+ AWESOME → {% assign var10 = var9 | upcase %}{{ var10 }}
25
+ whatever-man → {% assign var11 = 'whatever man' || nil | replace:' ','-' %}{{ var11 }}
26
+
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octopress-assign-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 assign 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-assign-tag.rb
97
+ - lib/octopress-assign-tag/version.rb
98
+ - octopress-assign-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/assign-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 assign tag
128
+ test_files:
129
+ - test/.clash.yml
130
+ - test/Gemfile
131
+ - test/_config.yml
132
+ - test/_expected/index.html
133
+ - test/index.html