Class: Occams::Content::Tag::Children
- Inherits:
-
Occams::Content::Tag
- Object
- Occams::Content::Tag
- Occams::Content::Tag::Children
- Defined in:
- lib/occams/content/tags/children.rb
Overview
Nav Tag for unordered list of links to the children of the current page
{{ cms:children }}
{{ cms:children style: "font-weight: bold", exclude: "404-page, search-page" }}
To customize your children style, add a ‘children’ id to your CSS, e.g #children
color: #006633;
font-size: 90%;
margin-bottom: 4px;
font-style: italic;
and/or pass in style overrides with the ‘style’ parameter, as above
To exclude children, list their slugs with the ‘exclude’ parameter as comma-delimited string, e.g. as above - exclude: “404-page, search-page”
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#locals ⇒ Object
readonly
Returns the value of attribute locals.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Attributes inherited from Occams::Content::Tag
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(context:, params: [], source: nil) ⇒ Children
constructor
A new instance of Children.
Methods inherited from Occams::Content::Tag
Constructor Details
#initialize(context:, params: [], source: nil) ⇒ Children
Returns a new instance of Children.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/occams/content/tags/children.rb', line 21 def initialize(context:, params: [], source: nil) super @locals = params. @style = '' @style = "<style>#children {#{@locals['style']}}</style>" if @locals['style'] @exclude = [] @exclude = @locals['exclude'].split(',') if @locals['exclude'] @list = '' # ActiveRecord_Associations_CollectionProxy page_children = context.children.order(:position).to_ary page_children.delete_if { |child| @exclude.include? child.slug } return unless page_children.any? @list = '<ul id="children">' page_children.each do |c| next if Rails.env == 'production' && !c.is_published @list += "<li><a href=#{c.url(relative: true)}>#{c.label}</a></li>" end @list += '</ul>' end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
19 20 21 |
# File 'lib/occams/content/tags/children.rb', line 19 def list @list end |
#locals ⇒ Object (readonly)
Returns the value of attribute locals.
19 20 21 |
# File 'lib/occams/content/tags/children.rb', line 19 def locals @locals end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
19 20 21 |
# File 'lib/occams/content/tags/children.rb', line 19 def style @style end |
Instance Method Details
#content ⇒ Object
43 44 45 |
# File 'lib/occams/content/tags/children.rb', line 43 def content format("#{@style}#{@list}") end |