Module: ScriptFlow::Helpers

Defined in:
lib/script_flow/helpers.rb

Instance Method Summary collapse

Instance Method Details

#script(content = nil, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/script_flow/helpers.rb', line 4

def script(content = nil, &block)
  if content || block_given?
    if block_given?
      content = capture(&block)
    end
    if content
       case request.format
       when Mime::JS then
         script_flow.add_script(content)
         nil
       when Mime::HTML then
         javascript_tag(content)
       end
    end
  end
end

#script_for(identifier, content = nil, &block) ⇒ Object



21
22
23
# File 'lib/script_flow/helpers.rb', line 21

def script_for(identifier, content = nil, &block)
  content_for(identifier, script(content, &block))
end