public
Rubygem
Fork of nex3/haml
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/chriseppstein/haml.git
Search Repo:
Tagging version 1.7.2.

git-svn-id: svn://hamptoncatlin.com/haml/tags/rel_1-7-2@627 
7063305b-7217-0410-af8c-cdc13e5119b9
nex3 (author)
Sun Nov 18 19:48:42 -0800 2007
commit  d62b796a459ddb5cda1daf9331d8b706abdae8d6
tree    9f5754bb237c3a306fcbd2d8e5dfb862ddad8b38
parent  f3ff721a7671c7dc2094f9d09effadc0fb072c30
0
...
11
12
13
14
15
16
 
 
 
 
 
 
 
 
 
17
18
 
 
19
20
21
...
23
24
25
 
 
 
 
 
 
 
 
 
 
 
 
26
27
28
...
11
12
13
 
 
 
14
15
16
17
18
19
20
21
22
23
 
24
25
26
27
28
...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
0
@@ -11,11 +11,18 @@ and providing elegant, easily understandable, and powerful syntax.
0
 
0
 == Using
0
 
0
-There are two ways to use Haml and Sass.
0
-The easiest is as a Rails plugin:
0
-Simply type <tt>./script/plugin install http://hamptoncatlin.com/haml/stable</tt>
0
+There are several ways to use Haml and Sass.
0
+They can be used as a plugins for Rails or Merb,
0
+or embedded on their own in other applications.
0
+The first step of all of these is to install the Haml gem:
0
+
0
+ gem install haml
0
+
0
+To install Haml and Sass as a Rails plugin,
0
+just run <tt>haml --rails path/to/rails/app</tt>
0
 and both Haml and Sass will be installed.
0
-Views with the <tt>.haml</tt> extension will automatically use Haml.
0
+Views with the <tt>.haml</tt> (or <tt>.html.haml</tt> for edge)
0
+extension will automatically use Haml.
0
 Sass is a little more complicated;
0
 <tt>.sass</tt> files should be placed in public/stylesheets/sass,
0
 where they'll be automatically compiled
0
@@ -23,6 +30,18 @@ to corresponding CSS files in public/stylesheets when needed
0
 (the Sass template directory is customizable...
0
 see the Sass module docs for details).
0
 
0
+For Merb, <tt>.html.haml</tt> views will work without any further modification.
0
+To enable Sass, you also need to add it add a dependency.
0
+To do so, just add
0
+
0
+ dependency "haml"
0
+
0
+to config/dependencies.rb.
0
+Then it'll work just like it does in Rails.
0
+
0
+To use Haml and Sass programatically,
0
+check out the RDocs for the Haml and Sass modules.
0
+
0
 == Formatting
0
 
0
 === Haml
...
67
68
69
 
70
71
72
...
74
75
76
 
77
78
79
...
93
94
95
 
 
 
 
96
97
98
...
67
68
69
70
71
72
73
...
75
76
77
78
79
80
81
...
95
96
97
98
99
100
101
102
103
104
0
@@ -67,6 +67,7 @@ unless ARGV[0] == 'benchmark'
0
       It was originally envisioned as a plugin for Ruby on Rails,
0
       but it can function as a stand-alone templating engine.
0
     END
0
+ #'
0
     
0
     readmes = FileList.new('*') do |list|
0
       list.exclude(/[a-z]/)
0
@@ -74,6 +75,7 @@ unless ARGV[0] == 'benchmark'
0
     end.to_a
0
     spec.executables = ['haml', 'html2haml', 'sass']
0
     spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile', 'init.rb'].to_a + readmes
0
+ spec.autorequire = ['haml', 'sass']
0
     spec.homepage = 'http://haml.hamptoncatlin.com/'
0
     spec.has_rdoc = true
0
     spec.extra_rdoc_files = readmes
0
@@ -93,6 +95,10 @@ unless ARGV[0] == 'benchmark'
0
     pkg.need_tar_bz2 = true
0
   end
0
 
0
+ task :install => [:package] do
0
+ sh %{gem install --no-ri pkg/haml-#{File.read('VERSION').strip}}
0
+ end
0
+
0
   # ----- Documentation -----
0
 
0
   require 'rake/rdoctask'
...
1
 
...
 
1
0
@@ -1 +1 @@
0
-1.7.1
0
+1.7.2
...
25
26
27
28
 
29
30
 
 
 
 
 
 
 
 
 
31
32
33
 
34
35
 
 
36
37
 
38
39
40
41
42
43
 
44
45
46
...
50
51
52
53
 
54
55
56
...
152
153
154
155
 
156
157
158
...
357
358
359
360
 
361
362
363
...
374
375
376
377
378
379
 
 
 
380
381
382
383
384
385
386
 
 
 
 
387
388
389
...
25
26
27
 
28
29
 
30
31
32
33
34
35
36
37
38
39
 
 
40
41
 
42
43
44
45
46
47
48
49
50
51
 
52
53
54
55
...
59
60
61
 
62
63
64
65
...
161
162
163
 
164
165
166
167
...
366
367
368
 
369
370
371
372
...
383
384
385
 
 
 
386
387
388
389
390
391
 
 
 
 
392
393
394
395
396
397
398
0
@@ -25,22 +25,31 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 #
0
 # Haml can be used in two ways:
0
 # as a plugin for Ruby on Rails,
0
-# and as a standalong Ruby module.
0
+# and as a standalone Ruby module.
0
 #
0
-# === Rails
0
+# Sass can be used in several ways:
0
+# As a template engine for Ruby on Rails or Merb,
0
+# or as a standalone engine.
0
+# The first step for all of these is to install the Haml gem:
0
+#
0
+# gem install haml
0
+#
0
+# To enable it as a Rails plugin,
0
+# then run
0
 #
0
-# Haml is most commonly used as a plugin.
0
-# It can be installed as a plugin using the Rails plugin installer:
0
+# haml --rails path/to/rails/app
0
 #
0
-# ./script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable
0
+# Haml is enabled in Merb by default,
0
+# so Merb users don't have to do anything more.
0
 #
0
 # Once it's installed, all view files with the ".haml" extension
0
+# (or ".html.haml" for Merb or edge Rails)
0
 # will be compiled using Haml.
0
 #
0
 # You can access instance variables in Haml templates
0
 # the same way you do in ERb templates.
0
 # Helper methods are also available in Haml templates.
0
-# For example:
0
+# For example (this example uses Rails, but the principle for Merb is the same):
0
 #
0
 # # file: app/controllers/movies_controller.rb
0
 #
0
@@ -50,7 +59,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 # end
0
 # end
0
 #
0
-# # file: app/views/movies/index.haml
0
+# -# file: app/views/movies/index.haml
0
 #
0
 # #content
0
 # .title
0
@@ -152,7 +161,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 # @user = CrazyUser.find(15)
0
 # end
0
 #
0
-# # file: app/views/users/show.haml
0
+# -# file: app/views/users/show.haml
0
 #
0
 # %div[@user]
0
 # %bar[290]/
0
@@ -357,7 +366,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 #
0
 # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
0
 #
0
-# If you're not using the UTF-8 characterset for your document,
0
+# If you're not using the UTF-8 character set for your document,
0
 # you can specify which encoding should appear
0
 # in the XML prolog in a similar way.
0
 # For example:
0
@@ -374,16 +383,16 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 # wraps all text after it in an HTML comment.
0
 # For example:
0
 #
0
-# %billabong
0
-# / This is the billabong element
0
-# I like billabongs!
0
+# %peanutbutterjelly
0
+# / This is the peanutbutterjelly element
0
+# I like sandwiches!
0
 #
0
 # is compiled to:
0
 #
0
-# <billabong>
0
-# <!-- This is the billabong element -->
0
-# I like billabongs!
0
-# </billabong>
0
+# <peanutbutterjelly>
0
+# <!-- This is the peanutbutterjelly element -->
0
+# I like sandwiches!
0
+# </peanutbutterjelly>
0
 #
0
 # The forward slash can also wrap indented sections of code. For example:
0
 #
...
123
124
125
126
 
127
128
129
...
228
229
230
231
 
232
233
234
...
123
124
125
 
126
127
128
129
...
228
229
230
 
231
232
233
234
0
@@ -123,7 +123,7 @@ END
0
         :suppress_eval => false,
0
         :attr_wrapper => "'",
0
         :locals => {},
0
- :autoclose => ['meta', 'img', 'link', 'br', 'hr'],
0
+ :autoclose => ['meta', 'img', 'link', 'br', 'hr', 'input', 'area'],
0
         :filters => {
0
           'sass' => Sass::Engine,
0
           'plain' => Haml::Filters::Plain,
0
@@ -228,7 +228,7 @@ END
0
       old_uline = nil
0
       (@template + "\n-#\n-#").each_with_index do |line, index|
0
         spaces, tabs = count_soft_tabs(line)
0
- uline = line.lstrip[0...-1]
0
+ uline = line.lstrip.chomp
0
         line = uline.rstrip
0
         
0
         if !line.empty?
...
1
2
3
4
5
6
7
8
9
10
11
 
12
13
14
...
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
0
@@ -1,14 +1,4 @@
0
-begin
0
- require 'rubygems'
0
- require 'active_support'
0
- require 'action_controller'
0
- require 'action_view'
0
- action_view_included = true
0
-rescue LoadError
0
- action_view_included = false
0
-end
0
-
0
-if action_view_included
0
+if defined?(ActionView) and not defined?(Merb::Plugins)
0
   module ActionView
0
     class Base # :nodoc:
0
       def render_with_haml(*args, &block)
...
20
21
22
23
24
25
 
 
 
26
27
28
 
29
30
31
 
 
 
 
 
 
 
 
 
 
 
32
33
 
34
35
 
36
37
38
...
41
42
43
44
45
46
47
48
 
 
49
50
51
...
394
395
396
397
 
398
399
400
...
562
563
564
565
 
566
567
568
...
573
574
575
 
 
 
 
 
 
 
 
576
577
578
 
 
 
579
580
581
582
 
 
 
583
584
585
586
 
587
588
589
590
591
592
 
 
593
594
595
596
 
...
20
21
22
 
 
 
23
24
25
26
27
28
29
30
 
 
31
32
33
34
35
36
37
38
39
40
41
42
 
43
44
 
45
46
47
48
...
51
52
53
 
 
 
 
 
54
55
56
57
58
...
401
402
403
 
404
405
406
407
...
569
570
571
 
572
573
574
575
...
580
581
582
583
584
585
586
587
588
589
590
591
 
 
592
593
594
595
596
 
 
597
598
599
600
601
602
 
603
604
605
606
 
 
 
607
608
609
610
611
612
613
0
@@ -20,19 +20,29 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 #
0
 # == Using Sass
0
 #
0
-# Sass can be used in two ways:
0
-# As a plugin for Ruby on Rails
0
-# and as a standalone parser.
0
+# Sass can be used in several ways:
0
+# As a plugin for Ruby on Rails or Merb,
0
+# or as a standalone parser.
0
 # Sass is bundled with Haml,
0
 # so if the Haml plugin or RubyGem is installed,
0
 # Sass will already be installed as a plugin or gem, respectively.
0
+# The first step for all of these is to install the Haml gem:
0
 #
0
-# To install Haml and Sass as a Ruby on Rails plugin,
0
-# use the normal Rails plugin installer:
0
+# gem install haml
0
+#
0
+# To enable it as a Rails plugin,
0
+# then run
0
+#
0
+# haml --rails path/to/rails/app
0
+#
0
+# To enable Sass in Merb,
0
+# add
0
+#
0
+# dependency "haml"
0
 #
0
-# ./script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable
0
+# to config/dependencies.rb.
0
 #
0
-# Sass templates in Rails don't quite function in the same way as views,
0
+# Sass templates in Rails and Merb don't quite function in the same way as views,
0
 # because they don't contain dynamic content,
0
 # and so only need to be compiled when the template file has been updated.
0
 # By default (see options, below),
0
@@ -41,11 +51,8 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 # For instance, public/stylesheets/sass/main.sass would be compiled to public/stylesheets/main.css.
0
 #
0
 # Using Sass in Ruby code is very simple.
0
-# First install the Haml/Sass RubyGem:
0
-#
0
-# gem install haml
0
-#
0
-# Then you can use it by including the "sass" gem
0
+# After installing the Haml gem,
0
+# you can use it by running <tt>require "sass"</tt>
0
 # and using Sass::Engine like so:
0
 #
0
 # engine = Sass::Engine.new("#main\n :background-color #0000ff")
0
@@ -394,7 +401,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 # but all constants in that file are made available in the current file.
0
 #
0
 # Sass looks for other Sass files in the working directory,
0
-# and the Sass file directory under Rails.
0
+# and the Sass file directory under Rails or Merb.
0
 # Additional search directories may be specified
0
 # using the :load_paths option (see below).
0
 #
0
@@ -562,7 +569,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 # time a controller is accessed,
0
 # as opposed to only when the template has been modified.
0
 # Defaults to false.
0
-# Only has meaning within Ruby on Rails.
0
+# Only has meaning within Ruby on Rails or Merb.
0
 #
0
 # [<tt>:always_check</tt>] Whether a Sass template should be checked for updates every
0
 # time a controller is accessed,
0
@@ -573,24 +580,34 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
0
 # true otherwise.
0
 # Only has meaning within Ruby on Rails.
0
 #
0
+# [<tt>:full_exception</tt>] Whether an error in the Sass code
0
+# should cause Sass to provide a detailed description.
0
+# If set to true, the specific error will be displayed
0
+# along with a line number and source snippet.
0
+# Otherwise, a simple uninformative error message will be displayed.
0
+# Defaults to false in production mode, true otherwise.
0
+# Only has meaning within Ruby on Rails or Merb.
0
+#
0
 # [<tt>:template_location</tt>] The directory where Sass templates should be read from.
0
-# Defaults to <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>.
0
-# Only has meaning within Ruby on Rails.
0
+# Defaults to <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>
0
+# or <tt>MERB_ROOT + "/public/stylesheets/sass"</tt>.
0
+# Only has meaning within Ruby on Rails or Merb.
0
 #
0
 # [<tt>:css_location</tt>] The directory where CSS output should be written to.
0
-# Defaults to <tt>RAILS_ROOT + "/public/stylesheets"</tt>.
0
-# Only has meaning within Ruby on Rails.
0
+# Defaults to <tt>RAILS_ROOT + "/public/stylesheets"</tt>
0
+# or <tt>MERB_ROOT + "/public/stylesheets"</tt>.
0
+# Only has meaning within Ruby on Rails or Merb.
0
 #
0
 # [<tt>:filename</tt>] The filename of the file being rendered.
0
 # This is used solely for reporting errors,
0
-# and is automatically set when using Rails.
0
+# and is automatically set when using Rails or Merb.
0
 #
0
 # [<tt>:load_paths</tt>] An array of filesystem paths which should be searched
0
 # for Sass templates imported with the "@import" directive.
0
-# This defaults to the working directory and, in Rails,
0
-# whatever <tt>:template_location</tt> is
0
-# (by default <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>).
0
+# This defaults to the working directory and, in Rails or Merb,
0
+# whatever <tt>:template_location</tt> is.
0
 #
0
 module Sass; end
0
 
0
 require 'sass/engine'
0
+require 'sass/plugin' if defined?(Merb::Plugins)
...
292
293
294
295
 
296
297
298
...
292
293
294
 
295
296
297
298
0
@@ -292,7 +292,7 @@ module Sass
0
         engine = nil
0
         filename = find_file_to_import(filename)
0
         if filename =~ /\.css$/
0
- nodes << Tree::ValueNode.new("@import #{filename}", @options[:style])
0
+ nodes << Tree::ValueNode.new("@import url(#{filename});", @options[:style])
0
         else
0
           File.open(filename) do |file|
0
             new_options = @options.dup
...
1
2
3
4
5
6
7
8
9
10
11
 
 
 
12
13
14
15
16
 
 
17
18
 
 
19
20
21
...
54
55
56
57
 
58
59
60
...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 
 
...
1
 
 
 
 
 
2
3
 
 
 
4
5
6
7
8
9
 
 
10
11
12
 
13
14
15
16
17
...
50
51
52
 
53
54
55
56
...
107
108
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
111
0
@@ -1,21 +1,17 @@
0
 require 'sass/engine'
0
-require 'rubygems'
0
-require 'action_controller'
0
-
0
-RAILS_ROOT = '. 'unless self.class.const_defined?('RAILS_ROOT')
0
-RAILS_ENV = 'production' unless self.class.const_defined?('RAILS_ENV')
0
 
0
 module Sass
0
- # This module contains methods that ActionController calls
0
- # to automatically update Sass templates that need updating.
0
- # It wasn't designed to be used outside of the context of ActionController.
0
+ # This module contains methods to aid in using Sass
0
+ # as a stylesheet-rendering plugin for various systems.
0
+ # Currently Rails/ActionController and Merb are supported out of the box.
0
   module Plugin
0
     class << self
0
       @@options = {
0
- :template_location => RAILS_ROOT + '/public/stylesheets/sass',
0
- :css_location => RAILS_ROOT + '/public/stylesheets',
0
+ :template_location => './public/stylesheets/sass',
0
+ :css_location => './public/stylesheets',
0
         :always_update => false,
0
- :always_check => RAILS_ENV != "production"
0
+ :always_check => true,
0
+ :full_exception => true
0
       }
0
 
0
       # Gets various options for Sass. See README for details.
0
@@ -54,7 +50,7 @@ module Sass
0
             begin
0
               result = engine.render
0
             rescue Exception => e
0
- if RAILS_ENV != "production"
0
+ if options[:full_exception]
0
                 e_string = "#{e.class}: #{e.message}"
0
 
0
                 if e.is_a? Sass::SyntaxError
0
@@ -111,17 +107,5 @@ module Sass
0
   end
0
 end
0
 
0
-# This module refers to the ActionController module that's part of Ruby on Rails.
0
-# Sass can be used as an alternate templating engine for Rails,
0
-# and includes some modifications to make this more doable.
0
-# The documentation can be found
0
-# here[http://rubyonrails.org/api/classes/ActionController/Base.html].
0
-module ActionController
0
- class Base # :nodoc:
0
- alias_method :sass_old_process, :process
0
- def process(*args)
0
- Sass::Plugin.update_stylesheets if Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
0
- sass_old_process(*args)
0
- end
0
- end
0
-end
0
+require 'sass/plugin/rails' if defined?(ActionController)
0
+require 'sass/plugin/merb' if defined?(Merb::Plugins)
...
1
2
3
4
5
 
6
 
 
 
 
 
7
8
9
...
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,9 +1,12 @@
0
-require File.dirname(__FILE__) + '/../lib/haml'
0
-require 'haml/template'
0
-require 'sass/engine'
0
 require 'rubygems'
0
 require 'active_support'
0
+require 'action_controller'
0
 require 'action_view'
0
+
0
+require File.dirname(__FILE__) + '/../lib/haml'
0
+require 'haml/template'
0
+require 'sass/engine'
0
+
0
 require 'benchmark'
0
 require 'stringio'
0
 
...
1
2
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1,5 +1,10 @@
0
 #!/usr/bin/env ruby
0
 
0
+require 'rubygems'
0
+require 'active_support'
0
+require 'action_controller'
0
+require 'action_view'
0
+
0
 require 'test/unit'
0
 require File.dirname(__FILE__) + '/../../lib/haml'
0
 require 'haml/engine'
...
1
2
 
 
 
 
 
3
4
5
...
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 
93
94
95
...
1
2
3
4
5
6
7
8
9
10
...
77
78
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
81
82
83
0
@@ -1,5 +1,10 @@
0
 #!/usr/bin/env ruby
0
 
0
+require 'rubygems'
0
+require 'active_support'
0
+require 'action_controller'
0
+require 'action_view'
0
+
0
 require 'test/unit'
0
 require File.dirname(__FILE__) + '/../../lib/haml'
0
 require 'haml/template'
0
@@ -72,24 +77,7 @@ class HelperTest < Test::Unit::TestCase
0
   def test_action_view_included
0
     assert(Haml::Helpers.action_view?)
0
   end
0
-
0
- def test_action_view_not_included
0
- #This is for 100% rcov, rather than any real testing purposes.
0
- Kernel.module_eval do
0
- alias_method :old_require, :require
0
- def require(string)
0
- raise LoadError if string == "action_view"
0
- old_require string
0
- end
0
- end
0
-
0
- load File.dirname(__FILE__) + '/../../lib/haml/helpers/action_view_mods.rb'
0
-
0
- Kernel.module_eval do
0
- alias_method :require, :old_require
0
- end
0
- end
0
-
0
+
0
   def test_form_tag
0
     result = render("- form_tag 'foo' do\n %p bar\n %strong baz", :action_view)
0
     should_be = "<form action=\"foo\" method=\"post\">\n <p>bar</p>\n <strong>baz</strong>\n</form>\n"
...
1
2
 
3
4
5
...
1
2
3
4
5
6
0
@@ -1,5 +1,6 @@
0
 require 'rubygems'
0
 require 'active_support'
0
+require 'action_controller'
0
 require 'action_view'
0
 require '../../lib/haml/template'
0
 require 'fileutils'
...
1
2
3
4
 
5
 
 
 
6
7
8
...
46
47
48
49
 
50
51
52
...
 
 
1
2
3
4
5
6
7
8
9
10
...
48
49
50
 
51
52
53
54
0
@@ -1,8 +1,10 @@
0
-require File.dirname(__FILE__) + '/../lib/haml'
0
-require 'haml/template'
0
 require 'rubygems'
0
 require 'active_support'
0
+require 'action_controller'
0
 require 'action_view'
0
+
0
+require File.dirname(__FILE__) + '/../lib/haml'
0
+require 'haml/template'
0
 require 'profiler'
0
 require 'stringio'
0
 
0
@@ -46,7 +48,7 @@ module Haml
0
     # automatically look for a haml template.
0
     #
0
     # Returns the results of the profiling as a string.
0
- def profile(runs = 100, template_name = 'standard')
0
+ def profile(runs = 100, template_name = 'standard')
0
       AbstractProfiler.profile(runs) { @base.render template_name }
0
     end
0
   end
...
1
2
3
 
 
 
4
5
6
 
 
 
7
8
9
...
14
15
16
17
18
19
20
21
22
23
24
 
25
26
27
...
40
41
42
43
 
44
45
46
...
49
50
51
52
53
 
 
54
55
56
57
58
59
60
 
61
62
63
 
64
65
66
...
69
70
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
73
74
...
85
86
87
 
 
 
 
 
 
 
 
 
 
88
89
90
...
1
2
 
3
4
5
6
7
8
9
10
11
12
13
14
...
19
20
21
 
 
 
 
 
 
 
 
22
23
24
25
...
38
39
40
 
41
42
43
44
...
47
48
49
 
 
50
51
52
53
54
55
56
57
 
58
59
60
 
61
62
63
64
...
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
0
@@ -1,9 +1,14 @@
0
 #!/usr/bin/env ruby
0
 
0
-RAILS_ENV = 'testing'
0
+MERB_ENV = RAILS_ENV = 'testing'
0
+RAILS_ROOT = '.'
0
+
0
 require 'test/unit'
0
 require 'fileutils'
0
 require File.dirname(__FILE__) + '/../../lib/sass'
0
+require 'rubygems'
0
+
0
+require 'action_controller'
0
 require 'sass/plugin'
0
 
0
 class SassPluginTest < Test::Unit::TestCase
0
@@ -14,14 +19,7 @@ class SassPluginTest < Test::Unit::TestCase
0
 
0
   def setup
0
     FileUtils.mkdir File.dirname(__FILE__) + '/tmp'
0
- Sass::Plugin.options = {
0
- :template_location => File.dirname(__FILE__) + '/templates',
0
- :css_location => File.dirname(__FILE__) + '/tmp',
0
- :style => :compact,
0
- :load_paths => [File.dirname(__FILE__) + '/results'],
0
- }
0
- Sass::Plugin.options[:always_update] = true
0
-
0
+ set_plugin_opts
0
     Sass::Plugin.update_stylesheets
0
   end
0
   
0
@@ -40,7 +38,7 @@ class SassPluginTest < Test::Unit::TestCase
0
     assert !Sass::Plugin.stylesheet_needs_update?('basic')
0
   end
0
   
0
- def test_exception_handling
0
+ def test_full_exception_handling
0
     File.delete(tempfile_loc('bork'))
0
     Sass::Plugin.update_stylesheets
0
     File.open(tempfile_loc('bork')) do |file|
0
@@ -49,18 +47,18 @@ class SassPluginTest < Test::Unit::TestCase
0
     File.delete(tempfile_loc('bork'))
0
   end
0
 
0
- def test_production_exception_handling
0
- Sass.const_set('RAILS_ENV', 'production')
0
+ def test_nonfull_exception_handling
0
+ Sass::Plugin.options[:full_exception] = false
0
 
0
     File.delete(tempfile_loc('bork'))
0
     Sass::Plugin.update_stylesheets
0
     assert_equal("/* Internal stylesheet error */", File.read(tempfile_loc('bork')))
0
     File.delete(tempfile_loc('bork'))
0
 
0
- Sass::Plugin.const_set('RAILS_ENV', 'testing')
0
+ Sass::Plugin.options[:full_exception] = true
0
   end
0
   
0
- def test_controller_process
0
+ def test_rails_update
0
     File.delete(tempfile_loc('basic'))
0
     assert Sass::Plugin.stylesheet_needs_update?('basic')
0
     
0
@@ -69,6 +67,27 @@ class SassPluginTest < Test::Unit::TestCase
0
     assert !Sass::Plugin.stylesheet_needs_update?('basic')
0
   end
0
 
0
+ def test_merb_update
0
+ begin
0
+ require 'merb'
0
+ rescue LoadError
0
+ puts "\nmerb couldn't be loaded, skipping a test"
0
+ return
0
+ end
0
+
0
+ require 'sass/plugin/merb'
0
+ MerbHandler.send(:define_method, :process_without_sass) { |*args| }
0
+ set_plugin_opts
0
+
0
+ File.delete(tempfile_loc('basic'))
0
+ assert Sass::Plugin.stylesheet_needs_update?('basic')
0
+
0
+ MerbHandler.new('.').process nil, nil
0
+
0
+ assert !Sass::Plugin.stylesheet_needs_update?('basic')
0
+ end
0
+
0
+
0
  private
0
  
0
   def assert_renders_correctly(name)
0
@@ -85,6 +104,16 @@ class SassPluginTest < Test::Unit::TestCase
0
   def result_loc(name)
0
     File.dirname(__FILE__) + "/results/#{name}.css"
0
   end
0
+
0
+ def set_plugin_opts
0
+ Sass::Plugin.options = {
0
+ :template_location => File.dirname(__FILE__) + '/templates',
0
+ :css_location => File.dirname(__FILE__) + '/tmp',
0
+ :style => :compact,
0
+ :load_paths => [File.dirname(__FILE__) + '/results'],
0
+ :always_update => true,
0
+ }
0
+ end
0
 end
0
 
0
 module Sass::Plugin