haml 1.5.1 → 1.5.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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.1
1
+ 1.5.2
data/lib/haml/engine.rb CHANGED
@@ -202,6 +202,7 @@ END
202
202
  def do_precompile
203
203
  push_silent <<-END
204
204
  def _haml_render
205
+ @haml_is_haml = true
205
206
  _hamlout = @haml_stack[-1]
206
207
  _erbout = _hamlout.buffer
207
208
  END
@@ -265,6 +266,7 @@ END
265
266
  # Close all the open tags
266
267
  @template_tabs.times { close }
267
268
 
269
+ push_silent "@haml_is_haml = false"
268
270
  push_silent "end"
269
271
  end
270
272
 
@@ -311,7 +313,7 @@ END
311
313
  sub_line = line[1..-1]
312
314
  unless sub_line[0] == SILENT_COMMENT
313
315
  mbk = mid_block_keyword?(line)
314
- push_silent(sub_line, !mbk)
316
+ push_silent(sub_line, !mbk, true)
315
317
  if (@block_opened && !mbk) || line[1..-1].split(' ', 2)[0] == "case"
316
318
  push_and_tabulate([:script])
317
319
  end
@@ -423,12 +425,14 @@ END
423
425
 
424
426
  # Evaluates <tt>text</tt> in the context of <tt>@scope_object</tt>, but
425
427
  # does not output the result.
426
- def push_silent(text, add_index = false)
427
- if add_index
428
- @precompiled << "@haml_lineno = #{@index}\n#{text}\n"
429
- else
430
- # Not really DRY, but probably faster
431
- @precompiled << "#{text}\n"
428
+ def push_silent(text, add_index = false, can_suppress = false)
429
+ unless can_suppress && @options[:suppress_eval]
430
+ if add_index
431
+ @precompiled << "@haml_lineno = #{@index}\n#{text}\n"
432
+ else
433
+ # Not really DRY, but probably faster
434
+ @precompiled << "#{text}\n"
435
+ end
432
436
  end
433
437
  end
434
438
 
@@ -517,7 +521,7 @@ END
517
521
 
518
522
  # Closes a Ruby block.
519
523
  def close_block
520
- push_silent "end"
524
+ push_silent "end", false, true
521
525
  @template_tabs -= 1
522
526
  end
523
527
 
@@ -541,7 +545,7 @@ END
541
545
 
542
546
  # Closes a loud Ruby block.
543
547
  def close_loud(command)
544
- push_silent 'end'
548
+ push_silent 'end', false, true
545
549
  @precompiled << command
546
550
  @template_tabs -= 1
547
551
  end
@@ -592,7 +596,7 @@ END
592
596
 
593
597
  value_exists = !value.empty?
594
598
  attributes_hash = "nil" if attributes_hash.nil? || @options[:suppress_eval]
595
- object_ref = "nil" unless object_ref
599
+ object_ref = "nil" if object_ref.nil? || @options[:suppress_eval]
596
600
 
597
601
  if @block_opened
598
602
  if atomic
data/lib/haml/helpers.rb CHANGED
@@ -229,7 +229,7 @@ module Haml
229
229
  # also works in other ActionView templates,
230
230
  # where it will always return false.
231
231
  def is_haml?
232
- @haml_stack ? @haml_stack.size > 0 : false
232
+ @haml_is_haml
233
233
  end
234
234
  end
235
235
  end
@@ -10,6 +10,18 @@ end
10
10
 
11
11
  if action_view_included
12
12
  module ActionView
13
+ class Base # :nodoc:
14
+ def render_with_haml(*args)
15
+ was_haml = is_haml?
16
+ @haml_is_haml = false
17
+ res = render_without_haml(*args)
18
+ @haml_is_haml = was_haml
19
+ res
20
+ end
21
+ alias_method :render_without_haml, :render
22
+ alias_method :render, :render_with_haml
23
+ end
24
+
13
25
  # This overrides various helpers in ActionView
14
26
  # to make them work more effectively with Haml.
15
27
  module Helpers
@@ -22,7 +34,8 @@ if action_view_included
22
34
  concat_without_haml(string, binding)
23
35
  end
24
36
  end
25
- alias_method_chain :concat, :haml
37
+ alias_method :concat_without_haml, :concat
38
+ alias_method :concat, :concat_with_haml
26
39
  end
27
40
 
28
41
  module FormTagHelper
@@ -40,7 +53,8 @@ if action_view_included
40
53
  concat "\n" if block_given? && is_haml?
41
54
  res
42
55
  end
43
- alias_method_chain :form_tag, :haml
56
+ alias_method :form_tag_without_haml, :form_tag
57
+ alias_method :form_tag, :form_tag_with_haml
44
58
  end
45
59
 
46
60
  module FormHelper
@@ -56,7 +70,8 @@ if action_view_included
56
70
  form_for_without_haml(object_name, *args, &proc)
57
71
  concat "\n" if block_given? && is_haml?
58
72
  end
59
- alias_method_chain :form_for, :haml
73
+ alias_method :form_for_without_haml, :form_for
74
+ alias_method :form_for, :form_for_with_haml
60
75
  end
61
76
 
62
77
  def generate_content_class_names
data/lib/sass.rb CHANGED
@@ -283,15 +283,15 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
283
283
  # they're simply joined with a space.
284
284
  # For example:
285
285
  #
286
- # !font_family = sans-serif
286
+ # !font_family = "sans-serif"
287
287
  # !main_font_size = 1em
288
288
  #
289
289
  # #main
290
290
  # :font
291
- # :family = !font-family
291
+ # :family = !font_family
292
292
  # :size = !main_font_size
293
293
  # h6
294
- # :font = italic small-caps bold (!main_font_size + 0.1em) !font-family
294
+ # :font = italic "small-caps" bold (!main_font_size + 0.1em) !font_family
295
295
  #
296
296
  # is compiled to:
297
297
  #
@@ -57,7 +57,9 @@ class EngineTest < Test::Unit::TestCase
57
57
 
58
58
  def test_stop_eval
59
59
  assert_equal("", render("= 'Hello'", :suppress_eval => true))
60
+ assert_equal("", render("- _hamlout << 'foo'", :suppress_eval => true))
60
61
  assert_equal("<div id='foo' />\n", render("#foo{:yes => 'no'}/", :suppress_eval => true))
62
+ assert_equal("<div />\n", render("%div[1]/", :suppress_eval => true))
61
63
 
62
64
  begin
63
65
  assert_equal("", render(":ruby\n puts 'hello'", :suppress_eval => true))
@@ -101,6 +101,10 @@ class HelperTest < Test::Unit::TestCase
101
101
 
102
102
  def test_is_haml
103
103
  assert(!ActionView::Base.new.is_haml?)
104
+ assert_equal("true\n", render("= is_haml?"))
105
+ assert_equal("true\n", render("= is_haml?", :action_view))
106
+ assert_equal("false", @base.render(:inline => '<%= is_haml? %>'))
107
+ assert_equal("false\n", render("= render :inline => '<%= is_haml? %>'", :action_view))
104
108
  end
105
109
  end
106
110
 
@@ -0,0 +1,15 @@
1
+ ;; Object results/
2
+ ;; SEMANTICDB Tags save file
3
+ (semanticdb-project-database-file "results/"
4
+ :tables (list
5
+ (semanticdb-table "helpers.xhtml"
6
+ :major-mode 'html-mode
7
+ :tags '(("Big!" section nil nil [566 682]) ("bar" section (:members (("here" section nil nil [801 1277]) ("google" section nil nil [1277 1280]))) nil [682 685]))
8
+ :file "helpers.xhtml"
9
+ :pointmax 1325
10
+ )
11
+ )
12
+ :file "semantic.cache"
13
+ :semantic-tag-version "2.0pre3"
14
+ :semanticdb-version "2.0pre3"
15
+ )
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: haml
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.5.1
7
- date: 2007-03-31 00:00:00 -07:00
6
+ version: 1.5.2
7
+ date: 2007-04-09 00:00:00 -07: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
@@ -86,6 +86,7 @@ files:
86
86
  - test/haml/results/silent_script.xhtml
87
87
  - test/haml/results/helpers.xhtml
88
88
  - test/haml/results/filters.xhtml
89
+ - test/haml/results/semantic.cache
89
90
  - test/haml/rhtml/standard.rhtml
90
91
  - test/haml/mocks/article.rb
91
92
  - test/haml/templates/standard.haml