app/services/model_controller/templates.rb in rademade_admin-0.0.1 vs app/services/model_controller/templates.rb in rademade_admin-0.0.2
- old
+ new
@@ -1,27 +1,25 @@
+# -*- encoding : utf-8 -*-
module RademadeAdmin
module Templates
def native_template_folder
- # 7 = "Admin::".length
+ # 15 = "RademadeAdmin::".length
# 11 = "Controller".length
# e.g. RademadeAdmin::QuestionAnswer::UsersController to "question_answer/users"
- self.class.to_s[7..-11].underscore
+ @native_template_folder ||= self.class.to_s[15..-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'
+ abstract_template((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}")
+ if template_exists?(template, "rademade_admin/#{native_template_folder}")
+ "rademade_admin/#{native_template_folder}/#{template}"
+ else
+ "rademade_admin/abstract/#{template}"
+ end
end
end
-end
\ No newline at end of file
+end