jekyll_include_plugin 1.1.1 → 1.3.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: 7df480b45b3043abaccf469a338b5c4cf49184772edfcfe7857675949b7dcfa3
4
- data.tar.gz: c14aa6edd200bb08a8f556676ea0594be2f74d07f8ea498987f57cab74e1e9c9
3
+ metadata.gz: bf5e2649753a79999e7dc654d94f74b2fb46bd3825d0724c045785fa67e12f2a
4
+ data.tar.gz: 516cc1d240386761f0ed7e315978d5c9280925732dcba575bfcc75cbd71e2f05
5
5
  SHA512:
6
- metadata.gz: a509ff2ab17aeaef3007185c137dc0985b00fb4652b171ebdb88ab227148650a320d4aee8efb7b30932d05d53cf132dc7541de4c070427100524c857842c9363
7
- data.tar.gz: b8926d41c0c06ff2aa5aa4bf55924da8a77e98cfcbba1bcbcd8de1b7b45614193858f6ff920da302ba50054f749f56ef4d5d2e0ad6f73ac152cce749aa111903
6
+ metadata.gz: ddc9154f479ac2f0592ac47e00599f4efe4057a58b5b5ca3d03ac3fb415cbc052354a77d3942ae685134c3f16351767fb0e5d0c658845833759e871263446d5a
7
+ data.tar.gz: f078a6a8c2f89fae4e3af7d620c6fe7aa2224b0d27144fa0ea25a267534e3c0532480a6901802ce3d8816e376fe61d661425b04af1319c6e4b76e95fe952fe9d
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby: [2.6.10, 2.7.6, 3.0.4, 3.1.2, 3.2.0-preview1]
10
+ ruby: [3.1.2, 3.2.0, 3.4.2]
11
11
  steps:
12
12
  - uses: actions/checkout@v2
13
13
  - name: Set up Ruby
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ .idea
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll_include_plugin (1.1.1)
4
+ jekyll_include_plugin (1.3.0)
5
5
  jekyll (>= 3.5, < 5.0)
6
6
  liquid (~> 4.0)
7
7
 
@@ -59,7 +59,8 @@ GEM
59
59
  rb-fsevent (0.11.0)
60
60
  rb-inotify (0.10.1)
61
61
  ffi (~> 1.0)
62
- rexml (3.2.5)
62
+ rexml (3.2.8)
63
+ strscan (>= 3.0.9)
63
64
  rouge (3.26.0)
64
65
  rspec (3.10.0)
65
66
  rspec-core (~> 3.10.0)
@@ -79,6 +80,7 @@ GEM
79
80
  ffi (~> 1.9)
80
81
  sassc (2.4.0-x64-mingw32)
81
82
  ffi (~> 1.9)
83
+ strscan (3.1.0)
82
84
  terminal-table (2.0.0)
83
85
  unicode-display_width (~> 1.1, >= 1.1.1)
84
86
  unicode-display_width (1.7.0)
@@ -93,4 +95,4 @@ DEPENDENCIES
93
95
  rspec (~> 3.0)
94
96
 
95
97
  BUNDLED WITH
96
- 2.2.20
98
+ 2.6.6
data/README.md CHANGED
@@ -60,6 +60,50 @@ Dynamic parameters:
60
60
  {% include_file "{{ $templatingAllowedHere }}/Dockerfile" snippet="{{ $hereToo }}" %}
61
61
  ```
62
62
 
63
+ ## Ignore a part of an included content
64
+
65
+ The usage:
66
+ ```jsx
67
+ const template = () => {
68
+ return (
69
+ // [<snippet example>]
70
+ <Provider
71
+ // [<ignore>]
72
+ propToIgnore={propToIgnore}
73
+ // [<endignore>]
74
+ component={() => <div>Data is loading...</div>}
75
+ errorComponent={({ message }) => <div>There was an error: {message}</div>}
76
+ >
77
+ ...
78
+ </Provider>
79
+ // [<endsnippet example>]
80
+ );
81
+ };
82
+ ```
83
+
84
+ The result:
85
+ ```jsx
86
+ <Provider
87
+ component={() => <div>Data is loading...</div>}
88
+ errorComponent={({ message }) => <div>There was an error: {message}</div>}
89
+ >
90
+ ...
91
+ </Provider>
92
+ ```
93
+
94
+ ## Plugin options in `_config.yml`
95
+
96
+ Default options:
97
+ ```yml
98
+ jekyll_include_plugin:
99
+ snippet_prefix: '...'
100
+ ```
101
+
102
+ ### `snippet_prefix`
103
+ Type: `string` Default: `...`
104
+
105
+ Prepends the prefix at the end of included snippet to differentiate whole file includes vs partial file includes (snippet)
106
+
63
107
  ## Installation
64
108
 
65
109
  Add this line to your application's Gemfile:
@@ -10,20 +10,23 @@ module JekyllIncludePlugin
10
10
  def initialize(tag_name, raw_markup, tokens)
11
11
  super
12
12
  @raw_markup = raw_markup
13
+ @config = {}
13
14
  @params = {}
14
15
  end
15
16
 
16
17
  def render(context)
18
+ read_config(context)
17
19
  parse_params(context)
18
20
 
19
21
  file_contents = get_raw_file_contents(context)
20
22
 
21
23
  if @params["snippet"]
22
- file_contents = pick_snippet(file_contents, @params["snippet"])
24
+ file_contents = pick_snippet(file_contents, @config['snippet_prefix'], @params["snippet"])
23
25
  else
24
26
  file_contents = remove_all_snippets(file_contents)
25
27
  end
26
28
 
29
+ file_contents = remove_ignored_lines(file_contents)
27
30
  file_contents = remove_excessive_newlines(file_contents)
28
31
  file_contents = remove_excessive_indentation(file_contents)
29
32
  file_contents = render_comments(file_contents, context.registers[:page]["lang"])
@@ -34,6 +37,13 @@ module JekyllIncludePlugin
34
37
 
35
38
  private
36
39
 
40
+ def read_config(context)
41
+ site = context.registers[:site]
42
+ plugin_config = site.config["jekyll_include_plugin"] || {}
43
+
44
+ @config["snippet_prefix"] = plugin_config['snippet_prefix'] || '...'
45
+ end
46
+
37
47
  def parse_params(context)
38
48
  rendered_markup = Liquid::Template
39
49
  .parse(@raw_markup)
@@ -16,7 +16,7 @@ module JekyllIncludePlugin
16
16
  module TextUtils
17
17
  include Utils
18
18
 
19
- def pick_snippet(text, snippet_name)
19
+ def pick_snippet(text, snippet_prefix, snippet_name)
20
20
  snippet_content = ""
21
21
  snippet_start_found = false
22
22
  snippet_end_found = false
@@ -42,8 +42,25 @@ module JekyllIncludePlugin
42
42
  abort("End of the snippet '#{snippet_name}' has not been found.") unless snippet_end_found
43
43
  abort("Snippet '#{snippet_name}' appears to be empty. Fix and retry.") if snippet_content.empty?
44
44
 
45
+ return snippet_content if snippet_prefix.empty?
46
+
45
47
  first_line_indent = %r!^\s*!.match(snippet_content)[0]
46
- return "#{first_line_indent}...\n#{snippet_content}"
48
+ return "#{first_line_indent}#{snippet_prefix}\n#{snippet_content}"
49
+ end
50
+
51
+ def remove_ignored_lines(text)
52
+ ignoring = false
53
+ text.each_line.reject do |line|
54
+ if line =~ /^\s*\/\/\s*\[<ignore>\]/
55
+ ignoring = true
56
+ true
57
+ elsif line =~ /^\s*\/\/\s*\[<endignore>\]/
58
+ ignoring = false
59
+ true
60
+ else
61
+ ignoring
62
+ end
63
+ end.join
47
64
  end
48
65
 
49
66
  def remove_all_snippets(text)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllIncludePlugin
4
- VERSION = "1.1.1"
4
+ VERSION = "1.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_include_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Lesikov
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-09-15 00:00:00.000000000 Z
10
+ date: 2025-03-19 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: liquid
@@ -72,7 +71,6 @@ dependencies:
72
71
  - - "~>"
73
72
  - !ruby/object:Gem::Version
74
73
  version: '3.0'
75
- description:
76
74
  email:
77
75
  - ilya@lesikov.com
78
76
  executables: []
@@ -101,7 +99,6 @@ licenses:
101
99
  metadata:
102
100
  homepage_uri: https://github.com/flant/jekyll_include_plugin
103
101
  source_code_uri: https://github.com/flant/jekyll_include_plugin
104
- post_install_message:
105
102
  rdoc_options: []
106
103
  require_paths:
107
104
  - lib
@@ -116,8 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
113
  - !ruby/object:Gem::Version
117
114
  version: '0'
118
115
  requirements: []
119
- rubygems_version: 3.0.8
120
- signing_key:
116
+ rubygems_version: 3.6.2
121
117
  specification_version: 4
122
118
  summary: Plugin for including contents of local/remote plain text files (or parts
123
119
  of them) into your pages. Allows for multilang comments in the included files.