Module: Impartial::Helper
- Defined in:
- lib/impartial/helper.rb
Class Method Summary collapse
Class Method Details
.find_class(name) ⇒ Object
21 22 23 24 25 |
# File 'lib/impartial/helper.rb', line 21 def self.find_class(name) name.to_s.camelize.constantize rescue NameError => e raise Impartial::Exceptions::ClassNotFound.new e.to_s end |
.impartial(name, *args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/impartial/helper.rb', line 10 def impartial(name, *args) cls = Impartial::Helper.find_class name puts cls.inspect puts cls.class.name view = cls.new *args path = cls.name.underscore shortname = cls.name.demodulize.underscore t = Rails.root.join("app", "impartials", path, "#{shortname}.html.hbs") Handlebars.compile(t.read).call(view).to_s.html_safe end |