sutty-liquid 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 297273ee3421e54485a3e5dcb5318f26a4c83a1be37b39b10e67d9b4d051867c
4
- data.tar.gz: 340d83e54a080233772571bc1bef3d7d46a04305a8da8a7e87e1d6b7d9389b00
3
+ metadata.gz: 01c1a35c0761f6c17219e3e9a06ddb2b949bf3b1433787700ade08620a55f49b
4
+ data.tar.gz: fc671ef7716697be23407fd269647f7b8b49973c6576d6c5d2a9b0007779d014
5
5
  SHA512:
6
- metadata.gz: 27f0b80e42f9236d74af8b88478507794ffdcd8b7c7f556719f77d6f3c1fd95f04df0200a1669cf187e20e22bab207832c17f164319d1386c1693e51df0b0f45
7
- data.tar.gz: f2d249f94e33161195357f173f154b5327f22bb8ae5b1bd34b39c95f9a77b1a34ca27b857de889cc2d28312a51402bdb2c0a77a48b62a183c47e197196157bec
6
+ metadata.gz: 46fa3a15890cdf1dcada8d15d339b2bd42aa1d36d87fff009da40662400779ba5e31c3af853717c75a838f7ad712a9e5b8d487cc58048ee6636473d70a257884
7
+ data.tar.gz: 6fdb47629110a3548141995992c7cf9392d7e4e214efb37921ba422aa72af4303f7e13f88319b115bd852e4af12f1e7e8c086ba074f89e8f53dae63a5648a940
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Filters
5
+ module Assertion
6
+ # Compares two values.
7
+ #
8
+ # Example usage:
9
+ #
10
+ # {{ item.url | equals: page.url }}
11
+ #
12
+ # @param [Any]
13
+ # @param [Any]
14
+ # @return [TrueClass|FalseClass]
15
+ def equals(input, comparison)
16
+ input == comparison
17
+ end
18
+
19
+ # Ternary operator. If the input value is truthy, return first
20
+ # argument, otherwise returns the last.
21
+ #
22
+ # Example usage:
23
+ #
24
+ # {% assign active = item.url | equals: page.url %}
25
+ # {{ active | ternary: 'active', '' }}
26
+ #
27
+ # @param [Any]
28
+ # @param [Any]
29
+ # @param [Any]
30
+ # @return [Any]
31
+ def ternary(input, value, alternative)
32
+ empty = case input
33
+ when Integer then input.zero?
34
+ when Float then input.zero?
35
+ when TrueClass then input
36
+ when FalseClass then input
37
+ when NilClass then false
38
+ else input.empty?
39
+ end
40
+
41
+ (empty || !!input) ? value : alternative
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ Liquid::Template.register_filter(Jekyll::Filters::Assertion)
@@ -5,6 +5,10 @@ module Jekyll
5
5
  module Compact
6
6
  # Removes nil values from an Array
7
7
  #
8
+ # Example usage:
9
+ #
10
+ # {{ 'tag,,tag2' | split: ',' | compact }}
11
+ #
8
12
  # @param [Array]
9
13
  # @return [Array]
10
14
  def compact(array)
@@ -3,7 +3,12 @@
3
3
  module Jekyll
4
4
  module Filters
5
5
  module DateLocal
6
- # Translates month and day names. This requires certain values on your _data/LANG.yml
6
+ # Translates month and day names. This requires certain values on
7
+ # your _data/LANG.yml
8
+ #
9
+ # Example usage:
10
+ #
11
+ # {{ page.date | date_local: '%e de %B de %Y' }}
7
12
  #
8
13
  # @see {_data/es.yml}
9
14
  # @param [String|Date]
@@ -3,7 +3,11 @@
3
3
  module Jekyll
4
4
  module Filters
5
5
  module File
6
- # File extension
6
+ # File extension.
7
+ #
8
+ # Example usage:
9
+ #
10
+ # {{ page.file.path | extname }}
7
11
  #
8
12
  # @param [String]
9
13
  # @return [Nil|String]
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
-
4
3
  module Jekyll
5
4
  module Filters
6
5
  module Json
7
6
  # Converts an object to JSON
8
7
  #
8
+ # Note: Jekyll 4 has a jsonify filter now.
9
+ #
9
10
  # @param [Any]
10
11
  # @return [String]
11
12
  def json(object)
@@ -5,6 +5,10 @@ module Jekyll
5
5
  # Extracts numbers from a String, useful for converting phone
6
6
  # numbers to tel: links.
7
7
  #
8
+ # Example usage:
9
+ #
10
+ # <a href="tel:{{ page.tel | numbers }}">{{ page.tel }}</a>
11
+ #
8
12
  # @param [String]
9
13
  # @return [String]
10
14
  module Numbers
@@ -4,6 +4,10 @@ module Jekyll
4
4
  module Filters
5
5
  module Pry
6
6
  # Pry into the input and args
7
+ #
8
+ # Example usage:
9
+ #
10
+ # {{ site.posts | pry }}
7
11
  def pry(input, *args)
8
12
  require 'pry'
9
13
 
@@ -3,7 +3,11 @@
3
3
  module Jekyll
4
4
  module Filters
5
5
  module Sample
6
- # Returns a random item from an Array
6
+ # Returns a random item from an Array.
7
+ #
8
+ # Example usage:
9
+ #
10
+ # {{ site.posts | sample }}
7
11
  #
8
12
  # @input [Array]
9
13
  # @return [Any]
@@ -7,6 +7,15 @@ module Jekyll
7
7
  # want to generate social network buttons from an undetermined
8
8
  # list of URLs.
9
9
  #
10
+ # Example usage:
11
+ #
12
+ # {% assign mastodon = 'https://todon.nl/@sutty' | social_network %}
13
+ # <a href="{{ mastodon.url }}">
14
+ # <i class="fa-{{ mastodon.name }}"></i>
15
+ #
16
+ # {{ mastodon.name | capitalize }}
17
+ # </a>
18
+ #
10
19
  # @param [String]
11
20
  # @return [Hash]
12
21
  def social_network(url)
@@ -4,6 +4,10 @@ module Jekyll
4
4
  module Tags
5
5
  class Pry < Liquid::Tag
6
6
  # Pry into the rendering context
7
+ #
8
+ # Example usage:
9
+ #
10
+ # {% pry %}
7
11
  def render(context)
8
12
  require 'pry'
9
13
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'jekyll/filters/assertion'
3
4
  require_relative 'jekyll/filters/compact'
4
5
  require_relative 'jekyll/filters/date_local'
5
6
  require_relative 'jekyll/filters/infinite'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sutty-liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-29 00:00:00.000000000 Z
11
+ date: 2020-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -35,6 +35,7 @@ extra_rdoc_files:
35
35
  files:
36
36
  - LICENSE.txt
37
37
  - README.md
38
+ - lib/jekyll/filters/assertion.rb
38
39
  - lib/jekyll/filters/compact.rb
39
40
  - lib/jekyll/filters/date_local.rb
40
41
  - lib/jekyll/filters/file.rb