Module: Reactive::Mvc::View::Helpers
- Defined in:
- lib/reactive-mvc/view/helpers.rb
Instance Method Summary collapse
- #inject_output_helpers ⇒ Object
- #output_helper_names ⇒ Object
- #read_output_helpers(names = output_helper_names) ⇒ Object
Instance Method Details
#inject_output_helpers ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/reactive-mvc/view/helpers.rb', line 3 def inject_output_helpers <<-EOS helpers_module = HelperModule.new #{output_helper_names.inspect}, <<-EOC #{read_output_helpers.gsub('#', '\#')} EOC extend(*helpers_module.helpers) EOS end |
#output_helper_names ⇒ Object
12 13 14 15 |
# File 'lib/reactive-mvc/view/helpers.rb', line 12 def output_helper_names parts = controller_name.split('/') (["application_helper.#{request.format}.rb"] + Enumerable::Enumerator.new(parts, :each_index).collect{|i| "#{parts[0..i].join('/')}_helper.#{request.format}.rb"}).uniq.select{|path| File.file?(Reactive.path_for(:helper, path))} end |
#read_output_helpers(names = output_helper_names) ⇒ Object
17 18 19 |
# File 'lib/reactive-mvc/view/helpers.rb', line 17 def read_output_helpers(names = output_helper_names) names.inject("") {|code, path| code << File.read(Reactive.path_for(:helper, path))} end |