Sha256: 4a89593642803a1f47169ac2a9d329bc9dda183816a3f977bb83c2119023014c

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

module RademadeAdmin
  module Templates

    def native_template_folder
      # 7 = "Admin::".length
      # 11 = "Controller".length
      # e.g. RademadeAdmin::QuestionAnswer::UsersController to "question_answer/users"
      self.class.to_s[7..-11].underscore
    end

    def template_folder
      #todo save in static variable
      template_exists?('_form', "rademade_admin/#{native_template_folder}") ? native_template_folder : 'abstract'
    end

    def form_template_path(real = false)
      "rademade_admin/#{template_folder}/" + (real ? '_' : '') + 'form'
    end

    def abstract_template(template)
      #todo if template doesn't exist in user application => render abstract template (form or view)
      "rademade_admin/abstract/#{template}"
      #unless template_exists?(template, "admin/#{native_template_folder}")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rademade_admin-0.0.1 app/services/model_controller/templates.rb