Sha256: 382ab3e61df733bebdfcaa8e6740b933096556c3958f4eafeefcf4269d768c6a

Contents?: true

Size: 788 Bytes

Versions: 4

Compression:

Stored size: 788 Bytes

Contents

# -*- encoding : utf-8 -*-
module RademadeAdmin
  module Templates

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

    def form_template_path(real = false)
      abstract_template((real ? '_' : '') + 'form')
    end

    def abstract_template(template)
      # TODO make with rails native controller extending
      if template_exists?(template, @template_service.template_path(native_template_folder))
        folder = native_template_folder
      else
        folder = 'abstract'
      end
      @template_service.template_path(folder, template)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rademade_admin-0.2.2 app/services/model_controller/templates.rb
rademade_admin-0.2.1 app/services/model_controller/templates.rb
rademade_admin-0.2.0 app/services/model_controller/templates.rb
rademade_admin-0.1.6 app/services/model_controller/templates.rb