Sha256: 7c51c30a3298cda1f7b17928fca166ca53deeea93267bc950cabdd34d17103c6

Contents?: true

Size: 835 Bytes

Versions: 5

Compression:

Stored size: 835 Bytes

Contents

module SimpleContentManagement::SimpleMenusHelper
	def simple_menu id, *content_tag_args, &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
		content_tag_args.any? ? content_tag(content_tag_args.shift, content, *content_tag_args) : content
	end

	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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
th_simple_content_management-0.2.7 app/helpers/simple_content_management/simple_menus_helper.rb
th_simple_content_management-0.2.6 app/helpers/simple_content_management/simple_menus_helper.rb
th_simple_content_management-0.2.5 app/helpers/simple_content_management/simple_menus_helper.rb
th_simple_content_management-0.2.4 app/helpers/simple_content_management/simple_menus_helper.rb
th_simple_content_management-0.2.3 app/helpers/simple_content_management/simple_menus_helper.rb