jekyll-cat 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c009189a0472310e08bd714370497c372fa32c034305911961e4768c5939c31e
4
- data.tar.gz: 39c45447f6acc6578a9a68e7e350047cf16608c6fbe962d054010cc9076c1f82
3
+ metadata.gz: e89900ae7cbf069394368c7e2f6ef493ba7fa670310fcc848bd256e821437b22
4
+ data.tar.gz: ebcc200009af876490c6dd451d082b22c3e2ec752958ad7bca3df2952928f4d9
5
5
  SHA512:
6
- metadata.gz: e7df718e05c4b7025ed8a40ec42554fdc1e52ffdaf32e83d09af104cbc1767ec102f5c5bac1761e3e993ce59fecaa8aee0ef142c10c1c695734e329c735994ba
7
- data.tar.gz: 19c662cd239261125358a2ff58639918af5b1487f528c3910e91d857493641e364f5ac32f5dc0468aa87d08ebde1bb726d2eebefcf684bdc6130815f815d456d
6
+ metadata.gz: d6332d4708c553758f2bacbba923b3487978a969d44420922fd7b04bf8544b622fc901ebda453979775cad06705ab039df6d5c3d5c5e53d478fc5140a0d0875a
7
+ data.tar.gz: d821edadb0689201d8273cdacfd096535fc0d5fba7ec24485ebfd07e66a01f2549c40e731f4f69f3401db4b05078ad08b72d7c35b05830e6ba4da438a54e6af0
data/.gitignore CHANGED
@@ -1,3 +1,15 @@
1
- _site/
2
- .sass-cache/
3
- .jekyll-metadata
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
data/README.md CHANGED
@@ -26,3 +26,9 @@ In liquid, use the `cat` tag to execute your include, passing the tag your path
26
26
  {% cat https://loripsum.net/api/ %}
27
27
  ```
28
28
 
29
+ ### Variable
30
+ ```
31
+ {% assign svg_path = 'assets/vector/my-svg-file.svg' %}
32
+ {% cat svg_path %}
33
+ ```
34
+
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "jekyll-cat"
3
- spec.version = '1.0.0'
3
+ spec.version = '1.1.0'
4
4
  spec.authors = ["Josh Davenport"]
5
5
  spec.email = ["josh@joshdavenport.co.uk"]
6
6
  spec.summary = 'Jekyll plugin providing a method to output contents of files and URLs'
@@ -5,40 +5,46 @@ require 'open-uri'
5
5
 
6
6
  module Jekyll
7
7
  class Cat < Liquid::Tag
8
-
9
8
  def initialize(tag_name, path, tokens)
10
9
  super
11
10
  @path = path
12
11
  end
13
12
 
14
13
  def render(context)
15
- if @path =~ URI::regexp
14
+ # parse what was passed to the tag, in case it was a variable
15
+ if "#{context[@path]}" != ""
16
+ path = "#{context[@path]}"
17
+ else
18
+ path = @path
19
+ end
20
+
21
+ # deal with the path, returning the content
22
+ if path =~ URI::regexp
16
23
  # the requested resource is a URL
17
- return render_url(context)
18
- elsif @path[0] == '/'
24
+ return render_url(context, path)
25
+ elsif path[0] == '/'
19
26
  # the requested resource is an file, specified with an absolute path
20
- return render_file_abs(context)
27
+ return render_file_abs(context, path)
21
28
  else
22
29
  # the requested resource is an file, specified with a relative path
23
- return render_file_rel(context)
24
- end
30
+ return render_file_rel(context, path)
31
+ end
25
32
  end
26
33
 
27
- def render_file_abs(context)
28
- file_path = @path
29
- content = File.read(file_path.strip!)
34
+ def render_file_abs(context, path)
35
+ content = File.read(path.strip)
30
36
  return content
31
37
  end
32
38
 
33
- def render_file_rel(context)
39
+ def render_file_rel(context, path)
34
40
  site_source = context.registers[:site].config['source']
35
- file_path = site_source + '/' + @path
36
- content = File.read(file_path.strip!)
41
+ file_path = site_source + '/' + path
42
+ content = File.read(file_path.strip)
37
43
  return content
38
44
  end
39
45
 
40
- def render_url(context)
41
- encoded_url = URI.encode(@path)
46
+ def render_url(context, path)
47
+ encoded_url = URI.encode(path)
42
48
  return open(encoded_url).read
43
49
  end
44
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-cat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Davenport