Class: Batman::DefineViewHelper::BatmanView

Inherits:
Object
  • Object
show all
Defined in:
lib/batman-rails/helpers/define_view_helper.rb

Constant Summary collapse

PATH_TO_HTML =
"app/assets/batman/html/"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pathname, render_context, options = {}) ⇒ BatmanView



24
25
26
27
28
# File 'lib/batman-rails/helpers/define_view_helper.rb', line 24

def initialize(pathname, render_context, options={})
  @pathname = pathname
  @render_context = render_context
  @path_to_html = options[:path_to_html] || PATH_TO_HTML
end

Instance Attribute Details

#path_to_htmlObject

Returns the value of attribute path_to_html.



13
14
15
# File 'lib/batman-rails/helpers/define_view_helper.rb', line 13

def path_to_html
  @path_to_html
end

#pathnameObject

Returns the value of attribute pathname.



13
14
15
# File 'lib/batman-rails/helpers/define_view_helper.rb', line 13

def pathname
  @pathname
end

#render_contextObject

Returns the value of attribute render_context.



13
14
15
# File 'lib/batman-rails/helpers/define_view_helper.rb', line 13

def render_context
  @render_context
end

Class Method Details

.all(render_context, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/batman-rails/helpers/define_view_helper.rb', line 15

def self.all(render_context, options={})
  path_to_html = options[:path_to_html] || PATH_TO_HTML
  glob_path = File.join(path_to_html, "**/*")
  valid_files = Dir.glob(glob_path).select { |pathname| File.file?(pathname) }
  valid_files.collect do |pathname|
    new(pathname, render_context, path_to_html: path_to_html)
  end
end

Instance Method Details

#inline_preload_javascriptObject



30
31
32
# File 'lib/batman-rails/helpers/define_view_helper.rb', line 30

def inline_preload_javascript
  %Q{Batman.View.store.set(#{name.to_json}, #{content.to_json});}
end