modular-jekyll 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: b2f39305bf891e0d72997031a89a97f683ef5114
4
- data.tar.gz: a6b30234305b9ef840eef7469cc3b1f4499815f3
3
+ metadata.gz: 27efccd404954392ff95873e31578316088a9c91
4
+ data.tar.gz: a90d7d366996026cf06baead95412e845c102396
5
5
  SHA512:
6
- metadata.gz: 298837c8146588fe3eaec1e9d7a438b9fef9ac55c2a6f22813c42190ab2b4b18918bb957400ba00f47eab598ccc8dcca18ff41c76db5f190853ce0d9937ceb7b
7
- data.tar.gz: 9b40d5e6bacf710a65bbd58bceefb84d0772db705a11c1056efedffd47da0c2cf7bcdd2f1b881d9a0b6452bc85397783930a1253311d1cdcbcbb47c8441820f1
6
+ metadata.gz: 57db14eaeff18f098bcade37755ec8f922c9f0e22f242c538bf8548d2df7a69c40138863131c02234252923c76897c2894cce16be2f8d3dcf33cdf88ee2b4393
7
+ data.tar.gz: f93629c4a5af9d94aa3f7a34f8be3edfe6fadc9631471e7d57bd436a5f5eef1acb22bb8c0ada7ebac40a50973a4e20fd7d2b56506098c9f066132e50c1221fb2
@@ -1,50 +1,55 @@
1
1
  require "modular/jekyll/version"
2
2
 
3
3
  module Modular
4
- module Jekyll < Jekyll::Generator
5
- def create_modular_content(page, modules, modules_dir)
6
- content = ''
7
-
8
- modules.each do | mod |
9
- module_html = '';
10
- params = Hash.new
11
-
12
- if mod.is_a? String
13
- # If we've a string, just load the file
14
- module_html = File.read File.join Dir.pwd, modules_dir, "#{mod}.html"
15
- else
16
- # Otherwise, we have params. Load the file and inject the params
17
- mod.select do |modName, modParams|
18
- module_html = File.read File.join Dir.pwd, modules_dir, "#{modName}.html"
19
- params['include'] = modParams
4
+ module Jekyll
5
+ class Generator < Jekyll::Generator
6
+ def create_modular_content(page, modules, modules_dir)
7
+ content = ''
8
+
9
+ modules.each do | mod |
10
+ module_html = '';
11
+ params = Hash.new
12
+
13
+ if mod.is_a? String
14
+ # If we've a string, just load the file
15
+ module_html = File.read File.join Dir.pwd, modules_dir, "#{mod}.html"
16
+ else
17
+ # Otherwise, we have params. Load the file and inject the params
18
+ mod.select do |modName, modParams|
19
+ module_html = File.read File.join Dir.pwd, modules_dir, "#{modName}.html"
20
+ params['include'] = modParams
21
+ end
22
+ end
23
+
24
+ # Pass page into our partial
25
+ params['page'] = page
26
+ tmpl = Liquid::Template.parse(module_html).render(params)
27
+
28
+ # Append it to the content
29
+ content += tmpl
20
30
  end
21
- end
22
31
 
23
- # Pass page into our partial
24
- params['page'] = page
25
- tmpl = Liquid::Template.parse(module_html).render(params)
32
+ content
33
+ end
26
34
 
27
- # Append it to the content
28
- content += tmpl
29
- end
35
+ def generate(site)
36
+ modules_dir = '_includes/modules'
37
+ if site.config['modules']
38
+ modules_dir = site.config['modules']
39
+ end
30
40
 
31
- content
32
- end
41
+ site.pages.map do | page |
42
+ if page.data['modules']
43
+ page.data['moduleContent'] = create_modular_content(
44
+ page,
45
+ page.data['modules'],
46
+ modules_dir
47
+ )
48
+ end
33
49
 
34
- def generate(site)
35
- modules_dir = site.config['modules']
36
- modules_dir = '_includes/modules' if not modules_dir else modules_dir
37
-
38
- site.pages.map do | page |
39
- if (page.data['modules'])
40
- page.data['moduleContent'] = create_modular_content(
41
- page,
42
- page.data['modules'],
43
- modules_dir
44
- )
50
+ page
51
+ end
45
52
  end
46
- page
47
53
  end
48
54
  end
49
- end
50
55
  end
@@ -1,5 +1,5 @@
1
1
  module Modular
2
2
  module Jekyll
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modular-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Dover