Sha256: 339fdedb28aa78cdf9b77a77592b48901daa81444adabeb960adbe42ed507eb0
Contents?: true
Size: 1.91 KB
Versions: 9
Compression:
Stored size: 1.91 KB
Contents
module Sugar module Actionview module Structure VIEW_PLACEHOLDERS = { 'create' => 'new', 'update' => 'edit' } def view_name action_name = controller.action_name VIEW_PLACEHOLDERS[action_name] || action_name end def default_page_title text = case action_name when 'index' controller_name.camelize when 'new', 'create' "#{t('krasivotokak.sugar.new', :default => 'New')} #{controller_name.classify.constantize.human_name}" when 'edit', 'update' "#{t('krasivotokak.sugar.edit', :default => 'Editing')} #{controller_name.classify.constantize.human_name}" else t("#{controller_name}.#{view_name}.title") end %(<span class="trasnlation_missing">#{text}</span>) end # Return page title for use in layout def page_title(title = nil) @page_title = if title title else @page_title || t("#{controller_name}.#{view_name}.title", :default => Rails.env.production? ? default_page_title : nil) end end def html_page_title(default = false, separator = ' | ') default ||= t('application.title') [page_title, default].compat.join(separator) end # Build simple navigation list def navigation_list(menu) returning '' do |result| menu.each do |item| path = "/#{item}" uri = request.request_uri title = t("#{item}.index.title", :default => item.to_s.camelize) result << content_tag(:li, :class => uri.starts_with?(path) ? 'selected' : nil) do link_to_unless_current(title, path) { content_tag(:strong, title) } end end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems