haml 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of haml might be problematic. Click here for more details.

data/README CHANGED
@@ -11,11 +11,18 @@ and providing elegant, easily understandable, and powerful syntax.
11
11
 
12
12
  == Using
13
13
 
14
- There are two ways to use Haml and Sass.
15
- The easiest is as a Rails plugin:
16
- Simply type <tt>./script/plugin install http://hamptoncatlin.com/haml/stable</tt>
14
+ There are several ways to use Haml and Sass.
15
+ They can be used as a plugins for Rails or Merb,
16
+ or embedded on their own in other applications.
17
+ The first step of all of these is to install the Haml gem:
18
+
19
+ gem install haml
20
+
21
+ To install Haml and Sass as a Rails plugin,
22
+ just run <tt>haml --rails path/to/rails/app</tt>
17
23
  and both Haml and Sass will be installed.
18
- Views with the <tt>.haml</tt> extension will automatically use Haml.
24
+ Views with the <tt>.haml</tt> (or <tt>.html.haml</tt> for edge)
25
+ extension will automatically use Haml.
19
26
  Sass is a little more complicated;
20
27
  <tt>.sass</tt> files should be placed in public/stylesheets/sass,
21
28
  where they'll be automatically compiled
@@ -23,6 +30,18 @@ to corresponding CSS files in public/stylesheets when needed
23
30
  (the Sass template directory is customizable...
24
31
  see the Sass module docs for details).
25
32
 
33
+ For Merb, <tt>.html.haml</tt> views will work without any further modification.
34
+ To enable Sass, you also need to add it add a dependency.
35
+ To do so, just add
36
+
37
+ dependency "haml"
38
+
39
+ to config/dependencies.rb.
40
+ Then it'll work just like it does in Rails.
41
+
42
+ To use Haml and Sass programatically,
43
+ check out the RDocs for the Haml and Sass modules.
44
+
26
45
  == Formatting
27
46
 
28
47
  === Haml
data/Rakefile CHANGED
@@ -67,6 +67,7 @@ unless ARGV[0] == 'benchmark'
67
67
  It was originally envisioned as a plugin for Ruby on Rails,
68
68
  but it can function as a stand-alone templating engine.
69
69
  END
70
+ #'
70
71
 
71
72
  readmes = FileList.new('*') do |list|
72
73
  list.exclude(/[a-z]/)
@@ -74,6 +75,7 @@ unless ARGV[0] == 'benchmark'
74
75
  end.to_a
75
76
  spec.executables = ['haml', 'html2haml', 'sass']
76
77
  spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile', 'init.rb'].to_a + readmes
78
+ spec.autorequire = ['haml', 'sass']
77
79
  spec.homepage = 'http://haml.hamptoncatlin.com/'
78
80
  spec.has_rdoc = true
79
81
  spec.extra_rdoc_files = readmes
@@ -93,6 +95,10 @@ unless ARGV[0] == 'benchmark'
93
95
  pkg.need_tar_bz2 = true
94
96
  end
95
97
 
98
+ task :install => [:package] do
99
+ sh %{gem install --no-ri pkg/haml-#{File.read('VERSION').strip}}
100
+ end
101
+
96
102
  # ----- Documentation -----
97
103
 
98
104
  require 'rake/rdoctask'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.1
1
+ 1.7.2
@@ -25,22 +25,31 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
25
25
  #
26
26
  # Haml can be used in two ways:
27
27
  # as a plugin for Ruby on Rails,
28
- # and as a standalong Ruby module.
28
+ # and as a standalone Ruby module.
29
29
  #
30
- # === Rails
30
+ # Sass can be used in several ways:
31
+ # As a template engine for Ruby on Rails or Merb,
32
+ # or as a standalone engine.
33
+ # The first step for all of these is to install the Haml gem:
34
+ #
35
+ # gem install haml
36
+ #
37
+ # To enable it as a Rails plugin,
38
+ # then run
31
39
  #
32
- # Haml is most commonly used as a plugin.
33
- # It can be installed as a plugin using the Rails plugin installer:
40
+ # haml --rails path/to/rails/app
34
41
  #
35
- # ./script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable
42
+ # Haml is enabled in Merb by default,
43
+ # so Merb users don't have to do anything more.
36
44
  #
37
45
  # Once it's installed, all view files with the ".haml" extension
46
+ # (or ".html.haml" for Merb or edge Rails)
38
47
  # will be compiled using Haml.
39
48
  #
40
49
  # You can access instance variables in Haml templates
41
50
  # the same way you do in ERb templates.
42
51
  # Helper methods are also available in Haml templates.
43
- # For example:
52
+ # For example (this example uses Rails, but the principle for Merb is the same):
44
53
  #
45
54
  # # file: app/controllers/movies_controller.rb
46
55
  #
@@ -50,7 +59,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
50
59
  # end
51
60
  # end
52
61
  #
53
- # # file: app/views/movies/index.haml
62
+ # -# file: app/views/movies/index.haml
54
63
  #
55
64
  # #content
56
65
  # .title
@@ -152,7 +161,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
152
161
  # @user = CrazyUser.find(15)
153
162
  # end
154
163
  #
155
- # # file: app/views/users/show.haml
164
+ # -# file: app/views/users/show.haml
156
165
  #
157
166
  # %div[@user]
158
167
  # %bar[290]/
@@ -261,8 +270,9 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
261
270
  # and is compiled to:
262
271
  #
263
272
  # <div id='collection'>
264
- # <div class='item'>Broken record album</div>
265
- # <div class='description'>What a cool item!</div>
273
+ # <div class='item'>
274
+ # <div class='description'>What a cool item!</div>
275
+ # </div>
266
276
  # </div>
267
277
  #
268
278
  # ==== =
@@ -356,7 +366,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
356
366
  #
357
367
  # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
358
368
  #
359
- # If you're not using the UTF-8 characterset for your document,
369
+ # If you're not using the UTF-8 character set for your document,
360
370
  # you can specify which encoding should appear
361
371
  # in the XML prolog in a similar way.
362
372
  # For example:
@@ -373,16 +383,16 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
373
383
  # wraps all text after it in an HTML comment.
374
384
  # For example:
375
385
  #
376
- # %billabong
377
- # / This is the billabong element
378
- # I like billabongs!
386
+ # %peanutbutterjelly
387
+ # / This is the peanutbutterjelly element
388
+ # I like sandwiches!
379
389
  #
380
390
  # is compiled to:
381
391
  #
382
- # <billabong>
383
- # <!-- This is the billabong element -->
384
- # I like billabongs!
385
- # </billabong>
392
+ # <peanutbutterjelly>
393
+ # <!-- This is the peanutbutterjelly element -->
394
+ # I like sandwiches!
395
+ # </peanutbutterjelly>
386
396
  #
387
397
  # The forward slash can also wrap indented sections of code. For example:
388
398
  #
@@ -573,7 +583,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
573
583
  # <p>
574
584
  # hello there you!
575
585
  # </p>
576
- #
586
+ #
577
587
  # ===== Blocks
578
588
  #
579
589
  # Ruby blocks, like XHTML tags, don't need to be explicitly closed in Haml.
@@ -623,6 +633,24 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
623
633
  # 2?
624
634
  # </p>
625
635
  #
636
+ # ==== -#
637
+ #
638
+ # The hyphen followed immediately by the pound sign
639
+ # signifies a silent comment.
640
+ # Any text following this isn't rendered in the resulting document
641
+ # at all.
642
+ #
643
+ # For example:
644
+ #
645
+ # %p foo
646
+ # -# This is a comment
647
+ # %p bar
648
+ #
649
+ # is compiled to:
650
+ #
651
+ # <p>foo</p>
652
+ # <p>bar</p>
653
+ #
626
654
  # == Other Useful Things
627
655
  #
628
656
  # === Helpers
@@ -167,7 +167,7 @@ module Haml
167
167
  " #{a}=#{attr_wrapper}#{v}#{attr_wrapper}"
168
168
  end
169
169
  end
170
- result.sort.join
170
+ result.compact.sort.join
171
171
  end
172
172
 
173
173
  # Returns whether or not the given value is short enough to be rendered
@@ -211,26 +211,3 @@ module Haml
211
211
  end
212
212
  end
213
213
  end
214
-
215
- unless String.methods.include? 'old_comp'
216
- class String # :nodoc
217
- alias_method :old_comp, :<=>
218
-
219
- def <=>(other)
220
- if other.is_a? NilClass
221
- -1
222
- else
223
- old_comp(other)
224
- end
225
- end
226
- end
227
-
228
- class NilClass # :nodoc:
229
- include Comparable
230
-
231
- def <=>(other)
232
- other.nil? ? 0 : 1
233
- end
234
- end
235
- end
236
-
@@ -123,7 +123,7 @@ END
123
123
  :suppress_eval => false,
124
124
  :attr_wrapper => "'",
125
125
  :locals => {},
126
- :autoclose => ['meta', 'img', 'link', 'br', 'hr'],
126
+ :autoclose => ['meta', 'img', 'link', 'br', 'hr', 'input', 'area'],
127
127
  :filters => {
128
128
  'sass' => Sass::Engine,
129
129
  'plain' => Haml::Filters::Plain,
@@ -228,7 +228,7 @@ END
228
228
  old_uline = nil
229
229
  (@template + "\n-#\n-#").each_with_index do |line, index|
230
230
  spaces, tabs = count_soft_tabs(line)
231
- uline = line.lstrip[0...-1]
231
+ uline = line.lstrip.chomp
232
232
  line = uline.rstrip
233
233
 
234
234
  if !line.empty?
@@ -721,7 +721,7 @@ END
721
721
  attributes_hash = "{nil}" if attributes_hash.nil? || literal_attributes || @options[:suppress_eval]
722
722
  object_ref = "nil" if object_ref.nil? || @options[:suppress_eval]
723
723
 
724
- if !attributes.empty? && '.#'.include?(attributes)
724
+ if attributes =~ /[\.#](\.|#|\z)/
725
725
  raise SyntaxError.new("Illegal element: classes and ids must have values. Use %div instead.")
726
726
  end
727
727
 
@@ -1,20 +1,10 @@
1
- begin
2
- require 'rubygems'
3
- require 'active_support'
4
- require 'action_controller'
5
- require 'action_view'
6
- action_view_included = true
7
- rescue LoadError
8
- action_view_included = false
9
- end
10
-
11
- if action_view_included
1
+ if defined?(ActionView) and not defined?(Merb::Plugins)
12
2
  module ActionView
13
3
  class Base # :nodoc:
14
- def render_with_haml(*args)
4
+ def render_with_haml(*args, &block)
15
5
  was_haml = is_haml?
16
6
  @haml_is_haml = false
17
- res = render_without_haml(*args)
7
+ res = render_without_haml(*args, &block)
18
8
  @haml_is_haml = was_haml
19
9
  res
20
10
  end
@@ -0,0 +1,30 @@
1
+ ***************
2
+ *** 1,11 ****
3
+ - begin
4
+ - require 'rubygems'
5
+ - require 'active_support'
6
+ - require 'action_controller'
7
+ - require 'action_view'
8
+ - action_view_included = true
9
+ - rescue LoadError
10
+ - action_view_included = false
11
+ end
12
+
13
+
14
+ --- 1,16 ----
15
+ +
16
+ + # This obviously requires that ActiveSupport be present prior to Haml
17
+ + # being loaded.
18
+ + action_view_included = false
19
+ + if defined?(ActiveSupport)
20
+ + begin
21
+ + require 'rubygems'
22
+ + require 'active_support'
23
+ + require 'action_controller'
24
+ + require 'action_view'
25
+ + action_view_included = true
26
+ + rescue LoadError
27
+ + end
28
+ end
29
+
30
+
@@ -20,19 +20,29 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
20
20
  #
21
21
  # == Using Sass
22
22
  #
23
- # Sass can be used in two ways:
24
- # As a plugin for Ruby on Rails
25
- # and as a standalone parser.
23
+ # Sass can be used in several ways:
24
+ # As a plugin for Ruby on Rails or Merb,
25
+ # or as a standalone parser.
26
26
  # Sass is bundled with Haml,
27
27
  # so if the Haml plugin or RubyGem is installed,
28
28
  # Sass will already be installed as a plugin or gem, respectively.
29
+ # The first step for all of these is to install the Haml gem:
29
30
  #
30
- # To install Haml and Sass as a Ruby on Rails plugin,
31
- # use the normal Rails plugin installer:
31
+ # gem install haml
32
+ #
33
+ # To enable it as a Rails plugin,
34
+ # then run
35
+ #
36
+ # haml --rails path/to/rails/app
37
+ #
38
+ # To enable Sass in Merb,
39
+ # add
40
+ #
41
+ # dependency "haml"
32
42
  #
33
- # ./script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable
43
+ # to config/dependencies.rb.
34
44
  #
35
- # Sass templates in Rails don't quite function in the same way as views,
45
+ # Sass templates in Rails and Merb don't quite function in the same way as views,
36
46
  # because they don't contain dynamic content,
37
47
  # and so only need to be compiled when the template file has been updated.
38
48
  # By default (see options, below),
@@ -41,11 +51,8 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
41
51
  # For instance, public/stylesheets/sass/main.sass would be compiled to public/stylesheets/main.css.
42
52
  #
43
53
  # Using Sass in Ruby code is very simple.
44
- # First install the Haml/Sass RubyGem:
45
- #
46
- # gem install haml
47
- #
48
- # Then you can use it by including the "sass" gem
54
+ # After installing the Haml gem,
55
+ # you can use it by running <tt>require "sass"</tt>
49
56
  # and using Sass::Engine like so:
50
57
  #
51
58
  # engine = Sass::Engine.new("#main\n :background-color #0000ff")
@@ -394,7 +401,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
394
401
  # but all constants in that file are made available in the current file.
395
402
  #
396
403
  # Sass looks for other Sass files in the working directory,
397
- # and the Sass file directory under Rails.
404
+ # and the Sass file directory under Rails or Merb.
398
405
  # Additional search directories may be specified
399
406
  # using the :load_paths option (see below).
400
407
  #
@@ -562,7 +569,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
562
569
  # time a controller is accessed,
563
570
  # as opposed to only when the template has been modified.
564
571
  # Defaults to false.
565
- # Only has meaning within Ruby on Rails.
572
+ # Only has meaning within Ruby on Rails or Merb.
566
573
  #
567
574
  # [<tt>:always_check</tt>] Whether a Sass template should be checked for updates every
568
575
  # time a controller is accessed,
@@ -573,24 +580,34 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
573
580
  # true otherwise.
574
581
  # Only has meaning within Ruby on Rails.
575
582
  #
583
+ # [<tt>:full_exception</tt>] Whether an error in the Sass code
584
+ # should cause Sass to provide a detailed description.
585
+ # If set to true, the specific error will be displayed
586
+ # along with a line number and source snippet.
587
+ # Otherwise, a simple uninformative error message will be displayed.
588
+ # Defaults to false in production mode, true otherwise.
589
+ # Only has meaning within Ruby on Rails or Merb.
590
+ #
576
591
  # [<tt>:template_location</tt>] The directory where Sass templates should be read from.
577
- # Defaults to <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>.
578
- # Only has meaning within Ruby on Rails.
592
+ # Defaults to <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>
593
+ # or <tt>MERB_ROOT + "/public/stylesheets/sass"</tt>.
594
+ # Only has meaning within Ruby on Rails or Merb.
579
595
  #
580
596
  # [<tt>:css_location</tt>] The directory where CSS output should be written to.
581
- # Defaults to <tt>RAILS_ROOT + "/public/stylesheets"</tt>.
582
- # Only has meaning within Ruby on Rails.
597
+ # Defaults to <tt>RAILS_ROOT + "/public/stylesheets"</tt>
598
+ # or <tt>MERB_ROOT + "/public/stylesheets"</tt>.
599
+ # Only has meaning within Ruby on Rails or Merb.
583
600
  #
584
601
  # [<tt>:filename</tt>] The filename of the file being rendered.
585
602
  # This is used solely for reporting errors,
586
- # and is automatically set when using Rails.
603
+ # and is automatically set when using Rails or Merb.
587
604
  #
588
605
  # [<tt>:load_paths</tt>] An array of filesystem paths which should be searched
589
606
  # for Sass templates imported with the "@import" directive.
590
- # This defaults to the working directory and, in Rails,
591
- # whatever <tt>:template_location</tt> is
592
- # (by default <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>).
607
+ # This defaults to the working directory and, in Rails or Merb,
608
+ # whatever <tt>:template_location</tt> is.
593
609
  #
594
610
  module Sass; end
595
611
 
596
612
  require 'sass/engine'
613
+ require 'sass/plugin' if defined?(Merb::Plugins)
@@ -292,7 +292,7 @@ module Sass
292
292
  engine = nil
293
293
  filename = find_file_to_import(filename)
294
294
  if filename =~ /\.css$/
295
- nodes << Tree::ValueNode.new("@import #{filename}", @options[:style])
295
+ nodes << Tree::ValueNode.new("@import url(#{filename});", @options[:style])
296
296
  else
297
297
  File.open(filename) do |file|
298
298
  new_options = @options.dup
@@ -1,21 +1,17 @@
1
1
  require 'sass/engine'
2
- require 'rubygems'
3
- require 'action_controller'
4
-
5
- RAILS_ROOT = '. 'unless self.class.const_defined?('RAILS_ROOT')
6
- RAILS_ENV = 'production' unless self.class.const_defined?('RAILS_ENV')
7
2
 
8
3
  module Sass
9
- # This module contains methods that ActionController calls
10
- # to automatically update Sass templates that need updating.
11
- # It wasn't designed to be used outside of the context of ActionController.
4
+ # This module contains methods to aid in using Sass
5
+ # as a stylesheet-rendering plugin for various systems.
6
+ # Currently Rails/ActionController and Merb are supported out of the box.
12
7
  module Plugin
13
8
  class << self
14
9
  @@options = {
15
- :template_location => RAILS_ROOT + '/public/stylesheets/sass',
16
- :css_location => RAILS_ROOT + '/public/stylesheets',
10
+ :template_location => './public/stylesheets/sass',
11
+ :css_location => './public/stylesheets',
17
12
  :always_update => false,
18
- :always_check => RAILS_ENV != "production"
13
+ :always_check => true,
14
+ :full_exception => true
19
15
  }
20
16
 
21
17
  # Gets various options for Sass. See README for details.
@@ -54,7 +50,7 @@ module Sass
54
50
  begin
55
51
  result = engine.render
56
52
  rescue Exception => e
57
- if RAILS_ENV != "production"
53
+ if options[:full_exception]
58
54
  e_string = "#{e.class}: #{e.message}"
59
55
 
60
56
  if e.is_a? Sass::SyntaxError
@@ -111,17 +107,5 @@ module Sass
111
107
  end
112
108
  end
113
109
 
114
- # This module refers to the ActionController module that's part of Ruby on Rails.
115
- # Sass can be used as an alternate templating engine for Rails,
116
- # and includes some modifications to make this more doable.
117
- # The documentation can be found
118
- # here[http://rubyonrails.org/api/classes/ActionController/Base.html].
119
- module ActionController
120
- class Base # :nodoc:
121
- alias_method :sass_old_process, :process
122
- def process(*args)
123
- Sass::Plugin.update_stylesheets if Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
124
- sass_old_process(*args)
125
- end
126
- end
127
- end
110
+ require 'sass/plugin/rails' if defined?(ActionController)
111
+ require 'sass/plugin/merb' if defined?(Merb::Plugins)
@@ -0,0 +1,20 @@
1
+ unless defined?(Sass::MERB_LOADED)
2
+ Sass::MERB_LOADED = true
3
+
4
+ Sass::Plugin.options.merge!(:template_location => MERB_ROOT + '/public/stylesheets/sass',
5
+ :css_location => MERB_ROOT + '/public/stylesheets',
6
+ :always_check => MERB_ENV != "production",
7
+ :full_exception => MERB_ENV != "production")
8
+ config = Merb::Plugins.config[:sass] || Merb::Plugins.config["sass"] || {}
9
+ config.symbolize_keys!
10
+ Sass::Plugin.options.merge!(config)
11
+
12
+ class MerbHandler # :nodoc:
13
+ def process_with_sass(request, response)
14
+ Sass::Plugin.update_stylesheets if Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
15
+ process_without_sass(request, response)
16
+ end
17
+ alias_method :process_without_sass, :process
18
+ alias_method :process, :process_with_sass
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ unless defined?(Sass::RAILS_LOADED)
2
+ Sass::RAILS_LOADED = true
3
+
4
+ Sass::Plugin.options.merge!(:template_location => RAILS_ROOT + '/public/stylesheets/sass',
5
+ :css_location => RAILS_ROOT + '/public/stylesheets',
6
+ :always_check => RAILS_ENV != "production",
7
+ :full_exception => RAILS_ENV != "production")
8
+
9
+ module ActionController # :nodoc:
10
+ class Base # :nodoc:
11
+ alias_method :sass_old_process, :process
12
+ def process(*args)
13
+ Sass::Plugin.update_stylesheets if Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
14
+ sass_old_process(*args)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,9 +1,12 @@
1
- require File.dirname(__FILE__) + '/../lib/haml'
2
- require 'haml/template'
3
- require 'sass/engine'
4
1
  require 'rubygems'
5
2
  require 'active_support'
3
+ require 'action_controller'
6
4
  require 'action_view'
5
+
6
+ require File.dirname(__FILE__) + '/../lib/haml'
7
+ require 'haml/template'
8
+ require 'sass/engine'
9
+
7
10
  require 'benchmark'
8
11
  require 'stringio'
9
12
 
@@ -1,5 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rubygems'
4
+ require 'active_support'
5
+ require 'action_controller'
6
+ require 'action_view'
7
+
3
8
  require 'test/unit'
4
9
  require File.dirname(__FILE__) + '/../../lib/haml'
5
10
  require 'haml/engine'
@@ -119,11 +124,6 @@ class EngineTest < Test::Unit::TestCase
119
124
  assert_equal("<p a='b2c'>\n</p>\n", render('%p{:a => "b#{1 + 1}c"}'))
120
125
  assert_equal("<p a='b2c'>\n</p>\n", render("%p{:a => 'b' + (1 + 1).to_s + 'c'}"))
121
126
  end
122
-
123
- def test_comps
124
- assert_equal(-1, "foo" <=> nil)
125
- assert_equal(1, nil <=> "foo")
126
- end
127
127
 
128
128
  def test_rec_merge
129
129
  hash1 = {1=>2, 3=>{5=>7, 8=>9}}
@@ -154,7 +154,7 @@ class EngineTest < Test::Unit::TestCase
154
154
  "a\n%p~\nb", "a\n~\nb", "a\n~\n b", "%p~\n b", "%p/\n a",
155
155
  "%p\n \t%a b", "%a\n b\nc", "%a\n b\nc",
156
156
  ":notafilter\n This isn't\n a filter!",
157
- ".{} a", "\#{} a", ".= 'foo'", "%a/ b" ]
157
+ ".{} a", "\#{} a", ".= 'foo'", "%a/ b", "%p..class", "%p..#." ]
158
158
  errs.each do |err|
159
159
  begin
160
160
  render(err)
@@ -1,5 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rubygems'
4
+ require 'active_support'
5
+ require 'action_controller'
6
+ require 'action_view'
7
+
3
8
  require 'test/unit'
4
9
  require File.dirname(__FILE__) + '/../../lib/haml'
5
10
  require 'haml/template'
@@ -72,24 +77,7 @@ class HelperTest < Test::Unit::TestCase
72
77
  def test_action_view_included
73
78
  assert(Haml::Helpers.action_view?)
74
79
  end
75
-
76
- def test_action_view_not_included
77
- #This is for 100% rcov, rather than any real testing purposes.
78
- Kernel.module_eval do
79
- alias_method :old_require, :require
80
- def require(string)
81
- raise LoadError if string == "action_view"
82
- old_require string
83
- end
84
- end
85
-
86
- load File.dirname(__FILE__) + '/../../lib/haml/helpers/action_view_mods.rb'
87
-
88
- Kernel.module_eval do
89
- alias_method :require, :old_require
90
- end
91
- end
92
-
80
+
93
81
  def test_form_tag
94
82
  result = render("- form_tag 'foo' do\n %p bar\n %strong baz", :action_view)
95
83
  should_be = "<form action=\"foo\" method=\"post\">\n <p>bar</p>\n <strong>baz</strong>\n</form>\n"
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'active_support'
3
+ require 'action_controller'
3
4
  require 'action_view'
4
5
  require '../../lib/haml/template'
5
6
  require 'fileutils'
@@ -1,8 +1,10 @@
1
- require File.dirname(__FILE__) + '/../lib/haml'
2
- require 'haml/template'
3
1
  require 'rubygems'
4
2
  require 'active_support'
3
+ require 'action_controller'
5
4
  require 'action_view'
5
+
6
+ require File.dirname(__FILE__) + '/../lib/haml'
7
+ require 'haml/template'
6
8
  require 'profiler'
7
9
  require 'stringio'
8
10
 
@@ -46,7 +48,7 @@ module Haml
46
48
  # automatically look for a haml template.
47
49
  #
48
50
  # Returns the results of the profiling as a string.
49
- def profile(runs = 100, template_name = 'standard')
51
+ def profile(runs = 100, template_name = 'standard')
50
52
  AbstractProfiler.profile(runs) { @base.render template_name }
51
53
  end
52
54
  end
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- RAILS_ENV = 'testing'
3
+ MERB_ENV = RAILS_ENV = 'testing'
4
+ RAILS_ROOT = '.'
5
+
4
6
  require 'test/unit'
5
7
  require 'fileutils'
6
8
  require File.dirname(__FILE__) + '/../../lib/sass'
9
+ require 'rubygems'
10
+
11
+ require 'action_controller'
7
12
  require 'sass/plugin'
8
13
 
9
14
  class SassPluginTest < Test::Unit::TestCase
@@ -14,14 +19,7 @@ class SassPluginTest < Test::Unit::TestCase
14
19
 
15
20
  def setup
16
21
  FileUtils.mkdir File.dirname(__FILE__) + '/tmp'
17
- Sass::Plugin.options = {
18
- :template_location => File.dirname(__FILE__) + '/templates',
19
- :css_location => File.dirname(__FILE__) + '/tmp',
20
- :style => :compact,
21
- :load_paths => [File.dirname(__FILE__) + '/results'],
22
- }
23
- Sass::Plugin.options[:always_update] = true
24
-
22
+ set_plugin_opts
25
23
  Sass::Plugin.update_stylesheets
26
24
  end
27
25
 
@@ -40,7 +38,7 @@ class SassPluginTest < Test::Unit::TestCase
40
38
  assert !Sass::Plugin.stylesheet_needs_update?('basic')
41
39
  end
42
40
 
43
- def test_exception_handling
41
+ def test_full_exception_handling
44
42
  File.delete(tempfile_loc('bork'))
45
43
  Sass::Plugin.update_stylesheets
46
44
  File.open(tempfile_loc('bork')) do |file|
@@ -49,18 +47,18 @@ class SassPluginTest < Test::Unit::TestCase
49
47
  File.delete(tempfile_loc('bork'))
50
48
  end
51
49
 
52
- def test_production_exception_handling
53
- Sass.const_set('RAILS_ENV', 'production')
50
+ def test_nonfull_exception_handling
51
+ Sass::Plugin.options[:full_exception] = false
54
52
 
55
53
  File.delete(tempfile_loc('bork'))
56
54
  Sass::Plugin.update_stylesheets
57
55
  assert_equal("/* Internal stylesheet error */", File.read(tempfile_loc('bork')))
58
56
  File.delete(tempfile_loc('bork'))
59
57
 
60
- Sass::Plugin.const_set('RAILS_ENV', 'testing')
58
+ Sass::Plugin.options[:full_exception] = true
61
59
  end
62
60
 
63
- def test_controller_process
61
+ def test_rails_update
64
62
  File.delete(tempfile_loc('basic'))
65
63
  assert Sass::Plugin.stylesheet_needs_update?('basic')
66
64
 
@@ -69,6 +67,27 @@ class SassPluginTest < Test::Unit::TestCase
69
67
  assert !Sass::Plugin.stylesheet_needs_update?('basic')
70
68
  end
71
69
 
70
+ def test_merb_update
71
+ begin
72
+ require 'merb'
73
+ rescue LoadError
74
+ puts "\nmerb couldn't be loaded, skipping a test"
75
+ return
76
+ end
77
+
78
+ require 'sass/plugin/merb'
79
+ MerbHandler.send(:define_method, :process_without_sass) { |*args| }
80
+ set_plugin_opts
81
+
82
+ File.delete(tempfile_loc('basic'))
83
+ assert Sass::Plugin.stylesheet_needs_update?('basic')
84
+
85
+ MerbHandler.new('.').process nil, nil
86
+
87
+ assert !Sass::Plugin.stylesheet_needs_update?('basic')
88
+ end
89
+
90
+
72
91
  private
73
92
 
74
93
  def assert_renders_correctly(name)
@@ -85,6 +104,16 @@ class SassPluginTest < Test::Unit::TestCase
85
104
  def result_loc(name)
86
105
  File.dirname(__FILE__) + "/results/#{name}.css"
87
106
  end
107
+
108
+ def set_plugin_opts
109
+ Sass::Plugin.options = {
110
+ :template_location => File.dirname(__FILE__) + '/templates',
111
+ :css_location => File.dirname(__FILE__) + '/tmp',
112
+ :style => :compact,
113
+ :load_paths => [File.dirname(__FILE__) + '/results'],
114
+ :always_update => true,
115
+ }
116
+ end
88
117
  end
89
118
 
90
119
  module Sass::Plugin
@@ -22,6 +22,6 @@ body { font: Arial; background: blue; }
22
22
  #content.user.show #container.top #column.right { width: 600px; }
23
23
  #content.user.show #container.bottom { background: brown; }
24
24
 
25
- @import basic.css
26
- @import ../results/complex.css
25
+ @import url(basic.css);
26
+ @import url(../results/complex.css);
27
27
  nonimported { myconst: hello; otherconst: goodbye; }
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: haml
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.7.1
7
- date: 2007-08-22 00:00:00 -07:00
6
+ version: 1.7.2
7
+ date: 2007-11-18 00:00:00 -08:00
8
8
  summary: An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.
9
9
  require_paths:
10
10
  - lib
@@ -13,6 +13,8 @@ homepage: http://haml.hamptoncatlin.com/
13
13
  rubyforge_project:
14
14
  description: Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML that's designed to express the structure of XHTML or XML documents in a non-repetitive, elegant, easy way, using indentation rather than closing tags and allowing Ruby to be embedded with ease. It was originally envisioned as a plugin for Ruby on Rails, but it can function as a stand-alone templating engine.
15
15
  autorequire:
16
+ - haml
17
+ - sass
16
18
  default_executable:
17
19
  bindir: bin
18
20
  has_rdoc: true
@@ -31,25 +33,27 @@ authors:
31
33
  files:
32
34
  - lib/sass.rb
33
35
  - lib/sass
34
- - lib/haml
35
- - lib/haml.rb
36
+ - lib/sass/plugin
37
+ - lib/sass/plugin/rails.rb
38
+ - lib/sass/plugin/merb.rb
36
39
  - lib/sass/error.rb
37
40
  - lib/sass/tree
38
- - lib/sass/constant.rb
39
- - lib/sass/constant
40
- - lib/sass/plugin.rb
41
- - lib/sass/css.rb
42
- - lib/sass/engine.rb
43
41
  - lib/sass/tree/value_node.rb
44
42
  - lib/sass/tree/attr_node.rb
45
43
  - lib/sass/tree/node.rb
46
44
  - lib/sass/tree/comment_node.rb
47
45
  - lib/sass/tree/rule_node.rb
46
+ - lib/sass/constant.rb
47
+ - lib/sass/constant
48
48
  - lib/sass/constant/color.rb
49
49
  - lib/sass/constant/string.rb
50
50
  - lib/sass/constant/number.rb
51
51
  - lib/sass/constant/operation.rb
52
52
  - lib/sass/constant/literal.rb
53
+ - lib/sass/plugin.rb
54
+ - lib/sass/css.rb
55
+ - lib/sass/engine.rb
56
+ - lib/haml
53
57
  - lib/haml/util.rb
54
58
  - lib/haml/exec.rb
55
59
  - lib/haml/html.rb
@@ -61,23 +65,22 @@ files:
61
65
  - lib/haml/engine.rb
62
66
  - lib/haml/helpers
63
67
  - lib/haml/helpers/action_view_extensions.rb
68
+ - lib/haml/helpers/action_view_mods.rb.rej
64
69
  - lib/haml/helpers/action_view_mods.rb
70
+ - lib/haml.rb
65
71
  - bin/css2sass
66
72
  - bin/sass
67
73
  - bin/haml
68
74
  - bin/html2haml
69
75
  - test/sass
70
- - test/haml
71
- - test/profile.rb
72
- - test/benchmark.rb
73
76
  - test/sass/templates
74
- - test/sass/plugin_test.rb
75
- - test/sass/results
76
- - test/sass/engine_test.rb
77
77
  - test/sass/templates/bork2.sass
78
78
  - test/sass/templates/expanded.sass
79
79
  - test/sass/templates/import.sass
80
80
  - test/sass/templates/subdir
81
+ - test/sass/templates/subdir/subdir.sass
82
+ - test/sass/templates/subdir/nested_subdir
83
+ - test/sass/templates/subdir/nested_subdir/nested_subdir.sass
81
84
  - test/sass/templates/basic.sass
82
85
  - test/sass/templates/nested.sass
83
86
  - test/sass/templates/compact.sass
@@ -87,11 +90,13 @@ files:
87
90
  - test/sass/templates/parent_ref.sass
88
91
  - test/sass/templates/bork.sass
89
92
  - test/sass/templates/complex.sass
90
- - test/sass/templates/subdir/subdir.sass
91
- - test/sass/templates/subdir/nested_subdir
92
- - test/sass/templates/subdir/nested_subdir/nested_subdir.sass
93
+ - test/sass/plugin_test.rb
94
+ - test/sass/results
93
95
  - test/sass/results/nested.css
94
96
  - test/sass/results/subdir
97
+ - test/sass/results/subdir/nested_subdir
98
+ - test/sass/results/subdir/nested_subdir/nested_subdir.css
99
+ - test/sass/results/subdir/subdir.css
95
100
  - test/sass/results/import.css
96
101
  - test/sass/results/compact.css
97
102
  - test/sass/results/expanded.css
@@ -100,19 +105,15 @@ files:
100
105
  - test/sass/results/constants.css
101
106
  - test/sass/results/parent_ref.css
102
107
  - test/sass/results/basic.css
103
- - test/sass/results/subdir/nested_subdir
104
- - test/sass/results/subdir/subdir.css
105
- - test/sass/results/subdir/nested_subdir/nested_subdir.css
108
+ - test/sass/engine_test.rb
109
+ - test/haml
106
110
  - test/haml/mocks
111
+ - test/haml/mocks/article.rb
107
112
  - test/haml/template_test.rb
108
113
  - test/haml/rhtml
114
+ - test/haml/rhtml/standard.rhtml
109
115
  - test/haml/helper_test.rb
110
116
  - test/haml/templates
111
- - test/haml/runner.rb
112
- - test/haml/results
113
- - test/haml/engine_test.rb
114
- - test/haml/mocks/article.rb
115
- - test/haml/rhtml/standard.rhtml
116
117
  - test/haml/templates/list.haml
117
118
  - test/haml/templates/_text_area.haml
118
119
  - test/haml/templates/_partial.haml
@@ -131,6 +132,8 @@ files:
131
132
  - test/haml/templates/helpers.haml
132
133
  - test/haml/templates/original_engine.haml
133
134
  - test/haml/templates/breakage.haml
135
+ - test/haml/runner.rb
136
+ - test/haml/results
134
137
  - test/haml/results/content_for_layout.xhtml
135
138
  - test/haml/results/just_stuff.xhtml
136
139
  - test/haml/results/whitespace_handling.xhtml
@@ -145,6 +148,9 @@ files:
145
148
  - test/haml/results/helpers.xhtml
146
149
  - test/haml/results/list.xhtml
147
150
  - test/haml/results/tag_parsing.xhtml
151
+ - test/haml/engine_test.rb
152
+ - test/profile.rb
153
+ - test/benchmark.rb
148
154
  - Rakefile
149
155
  - init.rb
150
156
  - VERSION