Sha256: 5916743b6afec9986ea6c902e079f36378070f8c1228ae8d5f7df6feabf5166d
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module Plate # An asset is a CoffeeScript or Sass file that needs to be compiled before writing # to the destination. class Asset < Page def engines @engines ||= self.extensions.reverse.collect { |e| self.site.registered_asset_engines[e.gsub(/\./, '').to_sym] }.reject { |e| !e } end def extensions @extensions ||= self.basename.scan(/\.[^.]+/) end def format_extension self.extensions.reverse.detect { |e| !self.site.asset_engine_extensions.include?(e) } end def file_path "#{directory}/#{file_name}" end def pathname File.dirname(self.file) end # Same as page, but no layout applied def rendered_content return @rendered_content if @rendered_content result = File.read(file) self.engines.each do |engine| template = engine.new() { result } result = template.render(self, :site => self.site) end @rendered_content = result end # Write this page to the destination. For static files this just results # in copying the file over to the destination def write! path = File.join(site.build_destination, file_path) FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'w') do |f| f.write(self.rendered_content) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
plate-0.5.4 | lib/plate/asset.rb |
plate-0.5.3 | lib/plate/asset.rb |