Sha256: 2c667c7316519d5329d4b7ba095930d0565de2b223660e81f94357704870ee59

Contents?: true

Size: 834 Bytes

Versions: 4

Compression:

Stored size: 834 Bytes

Contents

module Jsus
  module Util
    # Code generation routines.
    module CodeGenerator
      class <<self
        # @param [Array] paths list of paths
        # @return [String] javascript for includes for a list of given paths
        # @api public
        def generate_includes(paths)
          script = %{
          (function(prefix, loader) {
            var sources = %sources%;
            if (!loader) loader = function(path) {
              document.write('<scr' + 'ipt src="' + (prefix || '') + path + '"></script>');
            }
            for (var i = 0, j = sources.length; i < j; i++) loader(sources[i]);
          })(window.prefix, window.loader);}.sub("%sources%", JSON.pretty_generate(paths))
        end # generate_includes
      end # class <<self
    end # module CodeGenerator
  end # module Util
end # module Jsus

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jsus-0.4.0 lib/jsus/util/code_generator.rb
jsus-0.3.6 lib/jsus/util/code_generator.rb
jsus-0.3.5 lib/jsus/util/code_generator.rb
jsus-0.3.4 lib/jsus/util/code_generator.rb