2006-12-03 23:56:47 +00:00
|
|
|
require 'haml/engine'
|
2006-09-29 18:39:13 +00:00
|
|
|
|
|
|
|
module Haml
|
|
|
|
class Template
|
2006-10-30 06:59:57 +00:00
|
|
|
class << self
|
|
|
|
@@options = {}
|
2006-11-04 08:35:06 +00:00
|
|
|
|
2008-03-13 01:07:07 -07:00
|
|
|
# Gets various options for Haml. See README.rdoc for details.
|
2006-10-30 06:59:57 +00:00
|
|
|
def options
|
|
|
|
@@options
|
|
|
|
end
|
2006-11-04 08:35:06 +00:00
|
|
|
|
2008-03-13 01:07:07 -07:00
|
|
|
# Sets various options for Haml. See README.rdoc for details.
|
2006-10-30 06:59:57 +00:00
|
|
|
def options=(value)
|
|
|
|
@@options = value
|
|
|
|
end
|
|
|
|
end
|
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
|