Sha256: 52788846435f11d9f5859c59dbad2cf5371e8721fddf4689dbf882e7bae41947
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
class Jax::Packager::SprocketsTemplate < Sprockets::SourceFile def initialize(environment) pathname = environment.pathname_from(File.join(Jax.root, "template.js")) super(environment, pathname) end def template @template ||= begin template = [ 'Jax.environment = Jax.PRODUCTION;', '', '//= provide "public/"', '' ] Dir[Jax.root.join("app/**/*.js")].each do |jsfi| if File.file?(jsfi) relative_path = jsfi.sub(/^#{Regexp::escape Jax.root.to_s}[\/\\]?/, '') template << "//= require \"#{relative_path}\"" end end template.concat [ "if (Jax.doVersionCheck) Jax.doVersionCheck('#{Jax::Version::STRING}');", "else alert('Your Jax gem version is newer than your Jax JavaScript library!\n\nRun `rake jax:update` to fix this.');" ] template end end def source_lines # basically the same as super but with a string instead of a file # TODO would templating be a worthy addition to Sprockets itself? @lines ||= begin lines = [] comments = [] template.each_with_index do |line, lineno| lines << line = Sprockets::SourceLine.new(self, line, lineno+1) if line.begins_pdoc_comment? || comments.any? comments << line end if line.ends_multiline_comment? if line.ends_pdoc_comment? comments.each { |l| l.comment! } end comments.clear end end lines end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jax-0.0.0.5 | lib/jax/packager/sprockets_template.rb |