class Fangorn::Haml
Constants
- CACHE_BREAK
- SCRIPT_SOURCES
Public Class Methods
new(input)
click to toggle source
Calls superclass method
# File lib/fangorn/haml.rb, line 12 def initialize(input) super input, File.join(Output::dest, input.sub(File.join(Output::source, ''), '').sub(/\.haml$/, '')) end
Protected Instance Methods
cache_update(file)
click to toggle source
# File lib/fangorn/haml.rb, line 72 def cache_update(file) file + "?p=" + CACHE_BREAK end
copy_file(file) { |dirname, dirname, contents| ... }
click to toggle source
# File lib/fangorn/haml.rb, line 55 def copy_file(file) SCRIPT_SOURCES.each do |refdir, sourcedir| src = file.sub /^\/?#{refdir}\//, "#{sourcedir}/" if File.exists? src out = File.join(Output::dest, file) FileUtils.mkdir_p File.dirname(out) File.open(out, 'w') do |f| contents = File.read(src) f.write contents yield File.dirname(src), File.dirname(out), contents if block_given? end break end end end
create_command()
click to toggle source
# File lib/fangorn/haml.rb, line 17 def create_command File.open(@output, 'w') do |f| f.write ::Haml::Engine.new(File.read(@input)).render self, get_config end end
css_include(file)
click to toggle source
# File lib/fangorn/haml.rb, line 23 def css_include(file) copy_file file do |src, dest, css| css.scan(/url\(["']([\w\-\.\/]+).*?["']\)/).flatten.uniq.each do |path| reference = File.join(src, path) if File.exists? reference out = File.join(dest, path) FileUtils.mkdir_p File.dirname(out) File.open(out, 'w') do |f| f.write File.read(reference) end end end end ::Haml::Engine.new("%link{ rel: 'stylesheet', type: 'text/css', href: '#{cache_update file}' }").render end
css_include_tree(dir)
click to toggle source
# File lib/fangorn/haml.rb, line 39 def css_include_tree(dir) Dir[File.join(Output::dest, dir, '**', '*.css')].map do |file| css_include file.sub File.join(Output::dest, ''), (dir[0] == '/' ? '/' : '') end.join end
js_include(file)
click to toggle source
# File lib/fangorn/haml.rb, line 45 def js_include(file) copy_file file ::Haml::Engine.new("%script{ src: '#{cache_update file}' }").render end
js_include_tree(dir)
click to toggle source
# File lib/fangorn/haml.rb, line 49 def js_include_tree(dir) Dir[File.join(Output::dest, dir, '**', '*.js')].sort_by(&:length).map do |file| js_include file.sub File.join(Output::dest, ''), (dir[0] == '/' ? '/' : '') end.join end