Module: SimpleContentManagement::SimpleMenusHelper

Defined in:
app/helpers/simple_content_management/simple_menus_helper.rb

Instance Method Summary collapse

Instance Method Details

#simple_menu(id, *content_tag_args, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'app/helpers/simple_content_management/simple_menus_helper.rb', line 2

def simple_menu id, *, &block
	menu = SimpleContentManagement::SimpleMenu.find id
	content = "".html_safe
	menu.simple_menu_items.includes(:children).sort_by(&:position).each do |smi|
		smi.children.sort_by!(&:position)
		content << capture(smi, &block)
	end
	.any? ? (.shift, content, *) : content
end


12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/simple_content_management/simple_menus_helper.rb', line 12

def simple_menu_item_link_for smi
	if smi.uri[0] == "$"
		smc = SimpleContentManagement::SimpleMenu.find_registered_menu_item smi.uri[1..-1]
		if smc.condition.nil? || self.instance_eval(&smc.condition)
			link_to smi.name, *self.instance_eval(&smc.link)
		end
	else
		options = {}
		options[:target] = "_blank" if smi.is_target_blank?
		link_to smi.name, smi.uri, options
	end
end