[Sass] Added deprecation warning about the upcoming change to silent comments.

This commit is contained in:
Chris Eppstein 2009-02-25 08:53:32 -08:00
parent 8a5ae5ba6d
commit edc4c78df8
3 changed files with 21 additions and 2 deletions

View File

@ -136,6 +136,7 @@ module Sass
def split_lines def split_lines
@line = 0 @line = 0
old_tabs = nil old_tabs = nil
last_line_was_comment = false
@template.each_with_index do |line, index| @template.each_with_index do |line, index|
@line += 1 @line += 1
@ -143,6 +144,19 @@ module Sass
if line[0] == COMMENT_CHAR && line[1] == SASS_COMMENT_CHAR && tabs == 0 if line[0] == COMMENT_CHAR && line[1] == SASS_COMMENT_CHAR && tabs == 0
tabs = old_tabs tabs = old_tabs
last_line_was_comment = true
elsif last_line_was_comment && tabs
if tabs > 0
context = "On line #{@line}"
context << " of #{@options[:filename]}" if @options[:filename]
warn <<ENDENDEND
DEPRECATION WARNING:
#{context}
Silent comments (//) in version 2.2 will comment out the lines indented beneath them.
Please indent line #{@line - 1} to match the surrounding indentation level
ENDENDEND
end
last_line_was_comment = false
end end
if tabs # if line isn't blank if tabs # if line isn't blank

View File

@ -98,7 +98,13 @@ END
end end
def test_exception_line def test_exception_line
to_render = "rule\n :attr val\n// comment!\n\n :broken\n" to_render = <<SASS
rule
:attr val
// comment!
:broken
SASS
begin begin
Sass::Engine.new(to_render).render Sass::Engine.new(to_render).render
rescue Sass::SyntaxError => err rescue Sass::SyntaxError => err

View File

@ -79,7 +79,6 @@ body
:margin 0 5px :margin 0 5px
:padding 5px 5px 0 5px :padding 5px 5px 0 5px
:display inline :display inline
// This comment is in the middle of this rule
:font-size 1.1em :font-size 1.1em
// This comment is properly indented // This comment is properly indented
:color #fff :color #fff