Module: Hicube::ApplicationHelper
- Defined in:
- app/helpers/hicube/application_helper.rb
Instance Method Summary collapse
- #breadcrumbs ⇒ Object
- #heading ⇒ Object
- #root_path ⇒ Object
- #sidebar_class(action, model, options = {}) ⇒ Object
-
#snippet_render(name) ⇒ Object
def header_links Hicube::Page.parents end.
- #subheading ⇒ Object
Instance Method Details
#breadcrumbs ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/hicube/application_helper.rb', line 17 def return [] if controller_name.eql?('dashboards') case when current_page?(action: :index) { controller_name.camelize => {path: nil, active: true} } when current_page?(action: :new) { controller_name.camelize => {path: url_for(controller: controller_name, action: :index), active: false}, 'New' => {path: nil, active: true} } else # show & edit { controller_name.camelize => {path: url_for(controller: controller_name, action: :index), active: false}, instance_variable_get("@#{controller_name.singularize}") => {path: nil, active: true} } end end |
#heading ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/helpers/hicube/application_helper.rb', line 4 def heading if current_page?(action: :new) 'New' else instance_variable_get("@#{controller_name.singularize}") || controller_name.camelize end end |
#root_path ⇒ Object
56 57 58 |
# File 'app/helpers/hicube/application_helper.rb', line 56 def root_path '/' end |
#sidebar_class(action, model, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/helpers/hicube/application_helper.rb', line 35 def (action, model, = {}) case action when :edit, :new if .nil? current_page?(eval("#{action}_#{model}_path")) ? :active : nil rescue nil # for edit else current_page?(eval("#{action}_#{model}_path(options)")) ? :active : nil rescue nil # for edit end when :index current_page?(eval("#{model.to_s.pluralize}_path")) ? :active : nil when :show if .nil? current_page?(eval("#{model}_path")) ? :active : nil rescue nil else current_page?(eval("#{model}_path(options)")) ? :active : nil rescue nil end else nil end end |
#snippet_render(name) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'app/helpers/hicube/application_helper.rb', line 64 def snippet_render(name) snippet = Hicube::Snippet.find_by(name: name) raw "#{Hicube::Markdown.render(::Liquid::Template.parse(snippet.body).render).html_safe}" rescue Mongoid::Errors::DocumentNotFound => dnf raw "Snippet Not found with name #{name}" rescue Exception => e raw "#{e}" end |
#subheading ⇒ Object
12 13 14 15 |
# File 'app/helpers/hicube/application_helper.rb', line 12 def subheading return if controller_name.eql?('dashboards') controller_name.singularize.camelize unless current_page?(action: :index) end |