Sha256: fba7069cd21ed914d989c20e94ab46784da9d3e7184db2aa37edf4d488a7dd8f
Contents?: true
Size: 965 Bytes
Versions: 3
Compression:
Stored size: 965 Bytes
Contents
module CopyTunerClient class Copyray # Returns augmented HTML where the source is simply wrapped in an HTML # comment with filepath info. Xray.js uses these comments to associate # elements with the templates that rendered them. # # This: # <div class=".my-element"> # ... # </div> # # Becomes: # <!-- COPYRAY START 123 /path/to/file.html --> # <div class=".my-element"> # ... # </div> # <!-- COPYRAY END 123 --> def self.augment_template(source, key) id = next_id # skim doesn't allow html comments, so use skim's comment syntax if it's skim augmented = "<!--COPYRAY START #{id} #{key} #{CopyTunerClient.configuration.project_url} -->\n<span>#{source}</span>\n<!--COPYRAY END #{id}-->" ActiveSupport::SafeBuffer === source ? ActiveSupport::SafeBuffer.new(augmented) : augmented end def self.next_id @id = (@id ||= 0) + 1 end end end
Version data entries
3 entries across 3 versions & 1 rubygems