Permalink
Browse files

Tagging version 1.7.2.

git-svn-id: svn://hamptoncatlin.com/haml/tags/rel_1-7-2@627 7063305b-7217-0410-af8c-cdc13e5119b9
  • Loading branch information...
1 parent f3ff721 commit d62b796a459ddb5cda1daf9331d8b706abdae8d6 @nex3 nex3 committed Nov 19, 2007
View
27 README
@@ -11,18 +11,37 @@ and providing elegant, easily understandable, and powerful syntax.
== Using
-There are two ways to use Haml and Sass.
-The easiest is as a Rails plugin:
-Simply type <tt>./script/plugin install http://hamptoncatlin.com/haml/stable</tt>
+There are several ways to use Haml and Sass.
+They can be used as a plugins for Rails or Merb,
+or embedded on their own in other applications.
+The first step of all of these is to install the Haml gem:
+
+ gem install haml
+
+To install Haml and Sass as a Rails plugin,
+just run <tt>haml --rails path/to/rails/app</tt>
and both Haml and Sass will be installed.
-Views with the <tt>.haml</tt> extension will automatically use Haml.
+Views with the <tt>.haml</tt> (or <tt>.html.haml</tt> for edge)
+extension will automatically use Haml.
Sass is a little more complicated;
<tt>.sass</tt> files should be placed in public/stylesheets/sass,
where they'll be automatically compiled
to corresponding CSS files in public/stylesheets when needed
(the Sass template directory is customizable...
see the Sass module docs for details).
+For Merb, <tt>.html.haml</tt> views will work without any further modification.
+To enable Sass, you also need to add it add a dependency.
+To do so, just add
+
+ dependency "haml"
+
+to config/dependencies.rb.
+Then it'll work just like it does in Rails.
+
+To use Haml and Sass programatically,
+check out the RDocs for the Haml and Sass modules.
+
== Formatting
=== Haml
View
@@ -67,13 +67,15 @@ unless ARGV[0] == 'benchmark'
It was originally envisioned as a plugin for Ruby on Rails,
but it can function as a stand-alone templating engine.
END
+ #'
readmes = FileList.new('*') do |list|
list.exclude(/[a-z]/)
list.exclude('TODO')
end.to_a
spec.executables = ['haml', 'html2haml', 'sass']
spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile', 'init.rb'].to_a + readmes
+ spec.autorequire = ['haml', 'sass']
spec.homepage = 'http://haml.hamptoncatlin.com/'
spec.has_rdoc = true
spec.extra_rdoc_files = readmes
@@ -93,6 +95,10 @@ unless ARGV[0] == 'benchmark'
pkg.need_tar_bz2 = true
end
+ task :install => [:package] do
+ sh %{gem install --no-ri pkg/haml-#{File.read('VERSION').strip}}
+ end
+
# ----- Documentation -----
require 'rake/rdoctask'
View
@@ -1 +1 @@
-1.7.1
+1.7.2
View
@@ -25,22 +25,31 @@
#
# Haml can be used in two ways:
# as a plugin for Ruby on Rails,
-# and as a standalong Ruby module.
+# and as a standalone Ruby module.
#
-# === Rails
+# Sass can be used in several ways:
+# As a template engine for Ruby on Rails or Merb,
+# or as a standalone engine.
+# The first step for all of these is to install the Haml gem:
+#
+# gem install haml
+#
+# To enable it as a Rails plugin,
+# then run
#
-# Haml is most commonly used as a plugin.
-# It can be installed as a plugin using the Rails plugin installer:
+# haml --rails path/to/rails/app
#
-# ./script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable
+# Haml is enabled in Merb by default,
+# so Merb users don't have to do anything more.
#
# Once it's installed, all view files with the ".haml" extension
+# (or ".html.haml" for Merb or edge Rails)
# will be compiled using Haml.
#
# You can access instance variables in Haml templates
# the same way you do in ERb templates.
# Helper methods are also available in Haml templates.
-# For example:
+# For example (this example uses Rails, but the principle for Merb is the same):
#
# # file: app/controllers/movies_controller.rb
#
@@ -50,7 +59,7 @@
# end
# end
#
-# # file: app/views/movies/index.haml
+# -# file: app/views/movies/index.haml
#
# #content
# .title
@@ -152,7 +161,7 @@
# @user = CrazyUser.find(15)
# end
#
-# # file: app/views/users/show.haml
+# -# file: app/views/users/show.haml
#
# %div[@user]
# %bar[290]/
@@ -357,7 +366,7 @@
#
# <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
#
-# If you're not using the UTF-8 characterset for your document,
+# If you're not using the UTF-8 character set for your document,
# you can specify which encoding should appear
# in the XML prolog in a similar way.
# For example:
@@ -374,16 +383,16 @@
# wraps all text after it in an HTML comment.
# For example:
#
-# %billabong
-# / This is the billabong element
-# I like billabongs!
+# %peanutbutterjelly
+# / This is the peanutbutterjelly element
+# I like sandwiches!
#
# is compiled to:
#
-# <billabong>
-# <!-- This is the billabong element -->
-# I like billabongs!
-# </billabong>
+# <peanutbutterjelly>
+# <!-- This is the peanutbutterjelly element -->
+# I like sandwiches!
+# </peanutbutterjelly>
#
# The forward slash can also wrap indented sections of code. For example:
#
View
@@ -123,7 +123,7 @@ def initialize(template, l_options = {})
:suppress_eval => false,
:attr_wrapper => "'",
:locals => {},
- :autoclose => ['meta', 'img', 'link', 'br', 'hr'],
+ :autoclose => ['meta', 'img', 'link', 'br', 'hr', 'input', 'area'],
:filters => {
'sass' => Sass::Engine,
'plain' => Haml::Filters::Plain,
@@ -228,7 +228,7 @@ def #{method_name}(_haml_local_assigns)
old_uline = nil
(@template + "\n-#\n-#").each_with_index do |line, index|
spaces, tabs = count_soft_tabs(line)
- uline = line.lstrip[0...-1]
+ uline = line.lstrip.chomp
line = uline.rstrip
if !line.empty?
@@ -1,14 +1,4 @@
-begin
- require 'rubygems'
- require 'active_support'
- require 'action_controller'
- require 'action_view'
- action_view_included = true
-rescue LoadError
- action_view_included = false
-end
-
-if action_view_included
+if defined?(ActionView) and not defined?(Merb::Plugins)
module ActionView
class Base # :nodoc:
def render_with_haml(*args, &block)
View
@@ -20,19 +20,29 @@
#
# == Using Sass
#
-# Sass can be used in two ways:
-# As a plugin for Ruby on Rails
-# and as a standalone parser.
+# Sass can be used in several ways:
+# As a plugin for Ruby on Rails or Merb,
+# or as a standalone parser.
# Sass is bundled with Haml,
# so if the Haml plugin or RubyGem is installed,
# Sass will already be installed as a plugin or gem, respectively.
+# The first step for all of these is to install the Haml gem:
#
-# To install Haml and Sass as a Ruby on Rails plugin,
-# use the normal Rails plugin installer:
+# gem install haml
+#
+# To enable it as a Rails plugin,
+# then run
+#
+# haml --rails path/to/rails/app
+#
+# To enable Sass in Merb,
+# add
+#
+# dependency "haml"
#
-# ./script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable
+# to config/dependencies.rb.
#
-# Sass templates in Rails don't quite function in the same way as views,
+# Sass templates in Rails and Merb don't quite function in the same way as views,
# because they don't contain dynamic content,
# and so only need to be compiled when the template file has been updated.
# By default (see options, below),
@@ -41,11 +51,8 @@
# For instance, public/stylesheets/sass/main.sass would be compiled to public/stylesheets/main.css.
#
# Using Sass in Ruby code is very simple.
-# First install the Haml/Sass RubyGem:
-#
-# gem install haml
-#
-# Then you can use it by including the "sass" gem
+# After installing the Haml gem,
+# you can use it by running <tt>require "sass"</tt>
# and using Sass::Engine like so:
#
# engine = Sass::Engine.new("#main\n :background-color #0000ff")
@@ -394,7 +401,7 @@
# but all constants in that file are made available in the current file.
#
# Sass looks for other Sass files in the working directory,
-# and the Sass file directory under Rails.
+# and the Sass file directory under Rails or Merb.
# Additional search directories may be specified
# using the :load_paths option (see below).
#
@@ -562,7 +569,7 @@
# time a controller is accessed,
# as opposed to only when the template has been modified.
# Defaults to false.
-# Only has meaning within Ruby on Rails.
+# Only has meaning within Ruby on Rails or Merb.
#
# [<tt>:always_check</tt>] Whether a Sass template should be checked for updates every
# time a controller is accessed,
@@ -573,24 +580,34 @@
# true otherwise.
# Only has meaning within Ruby on Rails.
#
+# [<tt>:full_exception</tt>] Whether an error in the Sass code
+# should cause Sass to provide a detailed description.
+# If set to true, the specific error will be displayed
+# along with a line number and source snippet.
+# Otherwise, a simple uninformative error message will be displayed.
+# Defaults to false in production mode, true otherwise.
+# Only has meaning within Ruby on Rails or Merb.
+#
# [<tt>:template_location</tt>] The directory where Sass templates should be read from.
-# Defaults to <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>.
-# Only has meaning within Ruby on Rails.
+# Defaults to <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>
+# or <tt>MERB_ROOT + "/public/stylesheets/sass"</tt>.
+# Only has meaning within Ruby on Rails or Merb.
#
# [<tt>:css_location</tt>] The directory where CSS output should be written to.
-# Defaults to <tt>RAILS_ROOT + "/public/stylesheets"</tt>.
-# Only has meaning within Ruby on Rails.
+# Defaults to <tt>RAILS_ROOT + "/public/stylesheets"</tt>
+# or <tt>MERB_ROOT + "/public/stylesheets"</tt>.
+# Only has meaning within Ruby on Rails or Merb.
#
# [<tt>:filename</tt>] The filename of the file being rendered.
# This is used solely for reporting errors,
-# and is automatically set when using Rails.
+# and is automatically set when using Rails or Merb.
#
# [<tt>:load_paths</tt>] An array of filesystem paths which should be searched
# for Sass templates imported with the "@import" directive.
-# This defaults to the working directory and, in Rails,
-# whatever <tt>:template_location</tt> is
-# (by default <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>).
+# This defaults to the working directory and, in Rails or Merb,
+# whatever <tt>:template_location</tt> is.
#
module Sass; end
require 'sass/engine'
+require 'sass/plugin' if defined?(Merb::Plugins)
View
@@ -292,7 +292,7 @@ def import(files)
engine = nil
filename = find_file_to_import(filename)
if filename =~ /\.css$/
- nodes << Tree::ValueNode.new("@import #{filename}", @options[:style])
+ nodes << Tree::ValueNode.new("@import url(#{filename});", @options[:style])
else
File.open(filename) do |file|
new_options = @options.dup
View
@@ -1,21 +1,17 @@
require 'sass/engine'
-require 'rubygems'
-require 'action_controller'
-
-RAILS_ROOT = '. 'unless self.class.const_defined?('RAILS_ROOT')
-RAILS_ENV = 'production' unless self.class.const_defined?('RAILS_ENV')
module Sass
- # This module contains methods that ActionController calls
- # to automatically update Sass templates that need updating.
- # It wasn't designed to be used outside of the context of ActionController.
+ # This module contains methods to aid in using Sass
+ # as a stylesheet-rendering plugin for various systems.
+ # Currently Rails/ActionController and Merb are supported out of the box.
module Plugin
class << self
@@options = {
- :template_location => RAILS_ROOT + '/public/stylesheets/sass',
- :css_location => RAILS_ROOT + '/public/stylesheets',
+ :template_location => './public/stylesheets/sass',
+ :css_location => './public/stylesheets',
:always_update => false,
- :always_check => RAILS_ENV != "production"
+ :always_check => true,
+ :full_exception => true
}
# Gets various options for Sass. See README for details.
@@ -54,7 +50,7 @@ def update_stylesheets
begin
result = engine.render
rescue Exception => e
- if RAILS_ENV != "production"
+ if options[:full_exception]
e_string = "#{e.class}: #{e.message}"
if e.is_a? Sass::SyntaxError
@@ -111,17 +107,5 @@ def stylesheet_needs_update?(name)
end
end
-# This module refers to the ActionController module that's part of Ruby on Rails.
-# Sass can be used as an alternate templating engine for Rails,
-# and includes some modifications to make this more doable.
-# The documentation can be found
-# here[http://rubyonrails.org/api/classes/ActionController/Base.html].
-module ActionController
- class Base # :nodoc:
- alias_method :sass_old_process, :process
- def process(*args)
- Sass::Plugin.update_stylesheets if Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
- sass_old_process(*args)
- end
- end
-end
+require 'sass/plugin/rails' if defined?(ActionController)
+require 'sass/plugin/merb' if defined?(Merb::Plugins)
View
@@ -0,0 +1,20 @@
+unless defined?(Sass::MERB_LOADED)
+ Sass::MERB_LOADED = true
+
+ Sass::Plugin.options.merge!(:template_location => MERB_ROOT + '/public/stylesheets/sass',
+ :css_location => MERB_ROOT + '/public/stylesheets',
+ :always_check => MERB_ENV != "production",
+ :full_exception => MERB_ENV != "production")
+ config = Merb::Plugins.config[:sass] || Merb::Plugins.config["sass"] || {}
+ config.symbolize_keys!
+ Sass::Plugin.options.merge!(config)
+
+ class MerbHandler # :nodoc:
+ def process_with_sass(request, response)
+ Sass::Plugin.update_stylesheets if Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
+ process_without_sass(request, response)
+ end
+ alias_method :process_without_sass, :process
+ alias_method :process, :process_with_sass
+ end
+end
Oops, something went wrong.

0 comments on commit d62b796

Please sign in to comment.