Sha256: c1b204173bd2a0e96d317c4402016f3d28f3e0755e261b58a6e832ac6957e929

Contents?: true

Size: 894 Bytes

Versions: 5

Compression:

Stored size: 894 Bytes

Contents

# encoding: UTF-8

require 'coffee-script'
require 'simultaneous'

module Spontaneous::Output::Helpers
  module ScriptHelper
    extend self

    def scripts(*args)
      script_urls(*args).map { |script|
        script_tag(script)
      }.join("\n")
    end

    def script_urls(*args)
      unless site.model.mapper.editable?
        begin
          ::Simultaneous.send_event('publish_progress', {:state => "compiling assets", :progress => "*"}.to_json)
        rescue Errno::ECONNREFUSED
        rescue Errno::ENOENT
        end
      end
      options = args.extract_options!
      options.update(:development => development?)
      asset_environment.js(args.flatten, options)
    end

    alias_method :script, :scripts

    def script_tag(src)
      %(<script type="text/javascript" src="#{src}"></script>)
    end

    Spontaneous::Output::Helpers.register_helper(self, :html)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta10 lib/spontaneous/output/helpers/script_helper.rb
spontaneous-0.2.0.beta9 lib/spontaneous/output/helpers/script_helper.rb
spontaneous-0.2.0.beta8 lib/spontaneous/output/helpers/script_helper.rb
spontaneous-0.2.0.beta7 lib/spontaneous/output/helpers/script_helper.rb
spontaneous-0.2.0.beta6 lib/spontaneous/output/helpers/script_helper.rb