Sha256: 9f439db884aafbb4b55072893d59cf86a5b7819a3b78b48af769830d24d0fd17

Contents?: true

Size: 762 Bytes

Versions: 7

Compression:

Stored size: 762 Bytes

Contents

class FileReferenceFilter < Filter

  def file_reference(file)
    "{{FILEREF(#{file})}}"
  end
  
  def content_reference(file)
    "{{CONTENTREF(#{file})}}"
  end

  def filter_content(file, content, options)
    destination= File.expand_path(options.remove_prefix||"")
    
    content.gsub!(/\{\{FILEREF\(([^)]*)\)\}\}/) { |match|
      include_file= SourceFile.from_path($1)
      include_file.relative_to_folder(destination)
    }

    content.gsub!(/\{\{CONTENTREF\(([^)]*)\)\}\}/) { |match|
      include_file= SourceFile.from_path($1)
      included_content= include_file.filtered_content(options)
      included_content= include_file.minify_content(included_content)
      file.escape_embeded_content(included_content)
    }

    content
  end

  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
distil-0.10.4 lib/filters/file-reference-filter.rb
distil-0.10.3 lib/filters/file-reference-filter.rb
distil-0.10.1 lib/filters/file-reference-filter.rb
distil-0.10.0 lib/filters/file-reference-filter.rb
distil-0.8.4 lib/filters/file-reference-filter.rb
distil-0.8.2 lib/filters/file-reference-filter.rb
distil-0.8.1 lib/filters/file-reference-filter.rb