2006-12-03 23:56:47 +00:00
|
|
|
require 'haml/engine'
|
2006-09-29 18:39:13 +00:00
|
|
|
|
|
|
|
module Haml
|
2009-04-22 13:45:26 -07:00
|
|
|
module Template
|
|
|
|
extend self
|
2006-11-04 08:35:06 +00:00
|
|
|
|
2009-04-22 13:45:26 -07:00
|
|
|
@options = {}
|
|
|
|
attr_accessor :options
|
2006-09-29 18:39:13 +00:00
|
|
|
end
|
2006-10-14 22:24:53 +00:00
|
|
|
end
|
|
|
|
|
2007-12-15 21:07:27 +00:00
|
|
|
# Decide how we want to load Haml into Rails.
|
|
|
|
# Patching was necessary for versions <= 2.0.1,
|
|
|
|
# but we can make it a normal handler for higher versions.
|
|
|
|
if defined?(ActionView::TemplateHandler)
|
|
|
|
require 'haml/template/plugin'
|
|
|
|
else
|
|
|
|
require 'haml/template/patch'
|
2006-10-14 22:24:53 +00:00
|
|
|
end
|
2008-01-07 02:38:19 +00:00
|
|
|
|
2008-01-07 05:04:46 +00:00
|
|
|
if defined?(RAILS_ROOT)
|
|
|
|
# Update init.rb to the current version
|
|
|
|
# if it's out of date.
|
|
|
|
#
|
|
|
|
# We can probably remove this as of v1.9,
|
|
|
|
# because the new init file is sufficiently flexible
|
|
|
|
# to not need updating.
|
|
|
|
rails_init_file = File.join(RAILS_ROOT, 'vendor', 'plugins', 'haml', 'init.rb')
|
2008-04-10 21:39:48 -07:00
|
|
|
haml_init_file = Haml.scope('init.rb')
|
2008-05-24 12:19:18 -07:00
|
|
|
begin
|
|
|
|
if File.exists?(rails_init_file)
|
|
|
|
require 'fileutils'
|
|
|
|
FileUtils.cp(haml_init_file, rails_init_file) unless FileUtils.cmp(rails_init_file, haml_init_file)
|
|
|
|
end
|
|
|
|
rescue SystemCallError
|
|
|
|
warn <<END
|
|
|
|
HAML WARNING:
|
|
|
|
#{rails_init_file} is out of date and couldn't be automatically updated.
|
|
|
|
Please run `haml --rails #{File.expand_path(RAILS_ROOT)}' to update it.
|
|
|
|
END
|
2008-01-07 05:04:46 +00:00
|
|
|
end
|
2008-01-07 02:38:19 +00:00
|
|
|
end
|