mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] [SCSS] Add support for @for.
This commit is contained in:
parent
01494e94ab
commit
b3d72dbf37
3 changed files with 38 additions and 2 deletions
|
@ -44,6 +44,8 @@ module Sass
|
|||
'#{' => :begin_interpolation,
|
||||
'}' => :end_interpolation,
|
||||
';' => :semicolon,
|
||||
'{' => :lcurly,
|
||||
'}' => :rcurly,
|
||||
}
|
||||
|
||||
# A list of operator strings ordered with longer names first
|
||||
|
|
|
@ -42,6 +42,20 @@ module Sass
|
|||
expr
|
||||
end
|
||||
|
||||
# Parses a SassScript expression,
|
||||
# ending it when it encounters one of the givne identifier tokens.
|
||||
#
|
||||
# @param [#include?(String)] A set of strings that delimit the expression.
|
||||
# @return [Script::Node] The root node of the parse tree
|
||||
# @raise [Sass::SyntaxError] if the expression isn't valid SassScript
|
||||
def parse_until(tokens)
|
||||
@stop_at = tokens
|
||||
expr = assert_expr :expr
|
||||
assert_done
|
||||
expr.options = @options
|
||||
expr
|
||||
end
|
||||
|
||||
# Parses the argument list for a mixin include.
|
||||
#
|
||||
# @return [Array<Script::Node>] The root nodes of the arguments.
|
||||
|
@ -142,7 +156,10 @@ RUBY
|
|||
unary :not, :funcall
|
||||
|
||||
def funcall
|
||||
return paren unless name = try_tok(:ident)
|
||||
return paren unless @lexer.peek.type == :ident
|
||||
return if @stop_at && @stop_at.include?(@lexer.peek.value)
|
||||
|
||||
name = @lexer.next
|
||||
# An identifier without arguments is just a string
|
||||
unless try_tok(:lparen)
|
||||
filename = @options[:filename]
|
||||
|
|
|
@ -36,7 +36,7 @@ module Sass
|
|||
true
|
||||
end
|
||||
|
||||
DIRECTIVES = Set[:mixin, :include, :debug]
|
||||
DIRECTIVES = Set[:mixin, :include, :debug, :for]
|
||||
|
||||
def directive
|
||||
return unless name = tok(ATRULE)
|
||||
|
@ -80,6 +80,23 @@ module Sass
|
|||
node(Sass::Tree::DebugNode.new(sass_script_parser.parse))
|
||||
end
|
||||
|
||||
def for
|
||||
raw! '!'
|
||||
var = tok! IDENT
|
||||
ss
|
||||
|
||||
raw! 'from'
|
||||
from = sass_script_parser.parse_until Set["to", "through"]
|
||||
ss
|
||||
|
||||
@expected = '"to" or "through"'
|
||||
exclusive = (raw('to') || raw!('through')) == 'to'
|
||||
to = sass_script_parser.parse
|
||||
ss
|
||||
|
||||
block(node(Sass::Tree::ForNode.new(var, from, to, exclusive)))
|
||||
end
|
||||
|
||||
def variable
|
||||
return unless raw '!'
|
||||
name = tok! IDENT
|
||||
|
|
Loading…
Add table
Reference in a new issue