Methods
Instance Public methods
link_to_page(page, html_options={}, &block)
Link
Example:
link_to_page 123, class: "btn" do |page| "hello #{page.title}" end
Source: show
# File app/helpers/cardboard/public_helper.rb, line 9 def link_to_page(page, html_options={}, &block) raise ArgumentError, "Missing block" unless block_given? page = Cardboard::Page.where(id: page).first if page.is_a? Integer page = Cardboard::Page.where(identifier: page).first if page.is_a? String return nil if page.blank? link_to(capture(page, &block), page.url, html_options) end
meta_and_title(page)
Link
Example: head
= meta_and_title(current_page)
Source: show
# File app/helpers/cardboard/public_helper.rb, line 20 def meta_and_title(page) return nil unless page seo = page.meta_seo.dup html = "" html += "<title>#{seo.delete(:title)}</title>" if seo[:title] seo.each do |key, value| html += "<meta name='#{key}' content='#{value}' />\n" end html.html_safe end
nested_pages(page = nil, &block)
Link
Example 1:
#nested_pages Cardboard::Page.arrange do |page, subpages|
.indent = link_to(page.title, page.url) if page.in_menu? = subpages
end Example 2: %ul
= nested_pages do |page, subpages| %i = link_to page.title, edit_page_path(page) = content_tag(:ul, subpages) if subpages.present?
Source: show
# File app/helpers/cardboard/public_helper.rb, line 43 def nested_pages(page = nil, &block) raise ArgumentError, "Missing block" unless block_given? inner_nested_pages(Cardboard::Page.arrange(page), &block).html_safe end