sigmund_liquid 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDhkNjEyOTVmOWZmMDlhNmM0YmY1M2M1MWQ5NGZhMzZmNDIyNTgwNQ==
4
+ ZTc0NzQ4ZGQ2MjRhMWQ2NDg2NTA2NjA3M2VkMTZhNDNiNTZiNTU1Nw==
5
5
  data.tar.gz: !binary |-
6
- YzU5OTNlOGI4NDM1ZTc2ZDg4ZGRhZTE4NDRiZGY0ZjUwNDFlZDE3Mg==
6
+ ZjU5YTIyOWRmYmVhMTdmMDdmNmJkZGFjOWMwYzJkYWRhNWZmNWFmNg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MWU0ZTEzN2ZjMzcxN2FjYTgwMzgwMDdhMTIzN2U1YzRiMzU3OGQxM2YyZjNh
10
- ZjUyZmQ3NjcwMWQ1Y2ZmYmY5YTA3M2UyNWExZGE0ZDE5ZDZlZDZmYTQ0NDgx
11
- MDE1MzcwYTlhMGIxZDUzYjZjM2RlNjllNTdlNTY2NzYyYzZkMGU=
9
+ MDZiYTAyZDE2ZmRmNDVlNDkwMjkwODhhNWU0YWUxNGMxMzU4ZDAzYzEzNWFi
10
+ MjlhOTBmODcyNDY3MTMxYmE3OWFjNTdiMGQ3ZmExYTIzNDcyNmU2MzdmNDE1
11
+ MWU1NGU5YzFhOWE2ZGQyMjIwNzY3OTA3YmQxMzk4NWEyZDE5Nzk=
12
12
  data.tar.gz: !binary |-
13
- NjU0MjU5YTUwODM1MWE0NmEwYmY2OTZjMjRlNWNiZjg5ZjcxMWQ1OWUzMDNh
14
- YzkzNGNhNzE2MDE1OTA0ZDA2Mjg0NjNiZWEzYTc2NmRlOTllNTNiYTQyZjBh
15
- MDQ3MmI5M2FkNzUwNWM2MGYwYTZkYTgyODg5MTc0YTY1ZDcyNTM=
13
+ MjU0MTdlOGE1NDY4YWQ1M2VhMjhlNDI2MmMxZDM1NmZjNTkyYTdhYTBhMjg4
14
+ NmRiMjQ3ZjFjZGZjMDVlNzMzODNlMGUzNzMxMDgzODJhNzFmNmU0NzM5MWE3
15
+ OGYyOGJhNDM1Mjc5OThkMGEzNjM3YzRhYjBkNjg1YzU4MGY2NjI=
@@ -10,6 +10,12 @@ module Sigmund
10
10
  @options = { id: 'nav', depth: 1, class: '', active_class: 'active'}
11
11
  markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value.gsub(/"|'/, '') }
12
12
  @options[:exclude] = Regexp.new(@options[:exclude]) if @options[:exclude]
13
+
14
+ if @options[:snippet]
15
+ template = @options[:snippet].include?('{') ? @options[:snippet] : context[:site].snippets.where(slug: @options[:snippet] ).try(:first).try(:template)
16
+ @options[:liquid_render] = ::Liquid::Template.parse(template) unless template.blank?
17
+ end
18
+
13
19
  else
14
20
  raise ::Liquid::SyntaxError.new("Syntax Error in 'children_nav ' - Valid syntax: children_nav <options>")
15
21
  end
@@ -36,11 +42,14 @@ module Sigmund
36
42
  end
37
43
 
38
44
  # Returns a list element, a link to the page and its children
39
- def render_entry_link(context, page, css, depth)
45
+ def render_entry_link(context, page, css, depth, is_last, is_first )
40
46
  selected = @page.fullpath =~ /^#{page.fullpath}(\/.*)?$/ ? " #{@options[:active_class]}" : ''
41
47
 
42
48
  icon = @options[:icon] ? '<span></span>' : ''
43
- title = render_title(context, page)
49
+ title = render_title(context, page, is_first, is_last)
50
+ if @options[:liquid_render]
51
+ return title
52
+ end
44
53
  label = %{#{icon if @options[:icon] != 'after' }#{title}#{icon if @options[:icon] == 'after' }}
45
54
 
46
55
  href = File.join('/', @site.localized_page_fullpath(page))
@@ -63,7 +72,7 @@ module Sigmund
63
72
  css = []
64
73
  css << 'first' if children.first == c
65
74
  css << 'last' if children.last == c
66
- output << render_entry_link(context, c, css.join(' '), depth)
75
+ output << render_entry_link(context, c, css.join(' '), depth, children.first == c, children.last == c)
67
76
  end
68
77
  output << %{</ul>}
69
78
  end
@@ -71,10 +80,12 @@ module Sigmund
71
80
  output
72
81
  end
73
82
 
74
- def render_title(context, page)
83
+ def render_title(context, page, is_first, is_last)
75
84
  if @options[:liquid_render]
76
85
  context.stack do
77
86
  context['page'] = page
87
+ context['is_first'] = is_first
88
+ context['is_last'] = is_last
78
89
  @options[:liquid_render].render(context)
79
90
  end
80
91
  else
@@ -85,7 +85,10 @@ module Sigmund
85
85
  selected = @page.fullpath =~ /^#{page.fullpath}(\/.*)?$/ ? " #{@options[:active_class]}" : ''
86
86
 
87
87
  icon = @options[:icon] ? '<span></span>' : ''
88
- return title = render_title(context, page)
88
+ title = render_title(context, page)
89
+ if @options[:liquid_render]
90
+ return title
91
+ end
89
92
  label = %{#{icon if @options[:icon] != 'after' }#{title}#{icon if @options[:icon] == 'after' }}
90
93
 
91
94
  link_options = caret = ''
@@ -1,5 +1,5 @@
1
1
  module Sigmund
2
2
  module Liquid
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sigmund_liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - amainguy