Sha256: fca63a234414ea58e71269c735e35421931752eda86d74de8055a4d2bf809b06
Contents?: true
Size: 737 Bytes
Versions: 1
Compression:
Stored size: 737 Bytes
Contents
module Sidekick::Helpers::Compile # Compiles one template using the `tilt` gem. def compile(source, target) needs 'tilt', 'to compile templates' handling Exception, source do File.open(target, 'w') do |f| f.write(Tilt.new(source).render) end end end # watches for changes matching the `source` glob, and compiles to `target`, replacing ':name' in `target` with the basename of the changed file. def auto_compile(source, target) watch(source) do |files| files.each do |file| if File.exists?(file) t = target.gsub(':name', File.basename(file, '.*')) compile file, t log "render #{file} => #{t}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekick-0.6.2 | lib/sidekick/helpers/compile.rb |