Sha256: 83fd1fce65c2f16c690c28534154ee5d09e62d27108651f89829e116987dce99
Contents?: true
Size: 857 Bytes
Versions: 4
Compression:
Stored size: 857 Bytes
Contents
module Opal # A fragment holds a string of generated javascript that will be written # to the destination. It also keeps hold of the original sexp from which # it was generated. Using this sexp, when writing fragments in order, a # mapping can be created of the original location => target location, # aka, source-maps! class Fragment # String of javascript this fragment holds attr_reader :code def initialize(code, sexp = nil) @code = code.to_s @sexp = sexp end # In debug mode we may wish to include the original line as a comment def to_code if @sexp "/*:#{@sexp.line}*/#{@code}" else @code end end # inspect the contents of this fragment, f("fooo") def inspect "f(#{@code.inspect})" end def line @sexp.line if @sexp end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
opal-0.5.5 | lib/opal/fragment.rb |
opal-0.5.4 | lib/opal/fragment.rb |
opal-0.5.2 | lib/opal/fragment.rb |
opal-0.5.0 | lib/opal/fragment.rb |