Module: Haml
- Defined in:
- lib/gems/haml-2.0.4/lib/haml.rb,
lib/gems/haml-2.0.4/lib/haml/exec.rb,
lib/gems/haml-2.0.4/lib/haml/html.rb,
lib/gems/haml-2.0.4/lib/haml/error.rb,
lib/gems/haml-2.0.4/lib/haml/buffer.rb,
lib/gems/haml-2.0.4/lib/haml/engine.rb,
lib/gems/haml-2.0.4/lib/haml/filters.rb,
lib/gems/haml-2.0.4/lib/haml/filters.rb,
lib/gems/haml-2.0.4/lib/haml/helpers.rb,
lib/gems/haml-2.0.4/lib/haml/template.rb,
lib/gems/haml-2.0.4/lib/haml/precompiler.rb,
lib/gems/haml-2.0.4/lib/haml/template/plugin.rb,
lib/gems/haml-2.0.4/lib/haml/helpers/action_view_extensions.rb
Overview
:stopdoc: This file makes Haml work with Rails using the > 2.0.1 template handler API.
Defined Under Namespace
Modules: Exec, Filters, Helpers, Precompiler Classes: Buffer, Engine, Error, HTML, Plugin, SyntaxError, Template
Constant Summary collapse
- VERSION =
A string representing the version of Haml. A more fine-grained representation is generated by Haml.version.
Class Method Summary collapse
-
.init_rails(binding) ⇒ Object
This method is called by init.rb, which is run by Rails on startup.
-
.scope(file) ⇒ Object
Returns the path of file relative to the Haml root.
-
.version ⇒ Object
Returns a hash representing the version of Haml.
Class Method Details
.init_rails(binding) ⇒ Object
This method is called by init.rb, which is run by Rails on startup. We use it rather than putting stuff straight into init.rb so we can change the initialization behavior without modifying the file itself.
1034 1035 1036 1037 |
# File 'lib/gems/haml-2.0.4/lib/haml.rb', line 1034 def self.init_rails(binding) # No &method here for Rails 2.1 compatibility %w[haml/template sass sass/plugin].each {|f| require f} end |
.scope(file) ⇒ Object
Returns the path of file relative to the Haml root.
1021 1022 1023 |
# File 'lib/gems/haml-2.0.4/lib/haml.rb', line 1021 def self.scope(file) # :nodoc: File.join(File.dirname(__FILE__), '..', file) end |
.version ⇒ Object
Returns a hash representing the version of Haml. The :major, :minor, and :teeny keys have their respective numbers. The :string key contains a human-readable string representation of the version. If Haml is checked out from Git, the :rev key will have the revision hash.
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 |
# File 'lib/gems/haml-2.0.4/lib/haml.rb', line 986 def self.version return @@version if defined?(@@version) numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i } @@version = { :major => numbers[0], :minor => numbers[1], :teeny => numbers[2] } @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.') if File.exists?(scope('REVISION')) rev = File.read(scope('REVISION')).strip rev = nil if rev !~ /^([a-f0-9]+|\(.*\))$/ end if rev.nil? && File.exists?(scope('.git/HEAD')) rev = File.read(scope('.git/HEAD')).strip if rev =~ /^ref: (.*)$/ rev = File.read(scope(".git/#{$1}")).strip end end if rev @@version[:rev] = rev unless rev[0] == ?( @@version[:string] << "." @@version[:string] << rev[0...7] end end @@version end |