@@ -26,7 +26,7 @@ namespace Sass {
26
26
else root += importee;
27
27
if (!lex< exactly<' ;' > >()) throw_syntax_error (" top-level @import directive must be terminated by ';'" );
28
28
}
29
- else if (peek< mixin >() || peek< exactly<' =' > >()) {
29
+ else if (peek< mixin >() /* || peek< exactly<'='> >() */ ) {
30
30
root << parse_mixin_definition ();
31
31
}
32
32
else if (peek< function >()) {
@@ -42,9 +42,10 @@ namespace Sass {
42
42
else if ((lookahead_result = lookahead_for_selector (position)).found ) {
43
43
root << parse_ruleset (lookahead_result);
44
44
}
45
- else if (peek< include >() || peek< exactly<' +' > >()) {
46
- root << parse_mixin_call ();
47
- if (!lex< exactly<' ;' > >()) throw_syntax_error (" top-level @include directive must be terminated by ';'" );
45
+ else if (peek< include >() /* || peek< exactly<'+'> >() */ ) {
46
+ Node mixin_call (parse_mixin_call ());
47
+ root << mixin_call;
48
+ if (mixin_call.size () < 3 && !lex< exactly<' ;' > >()) throw_syntax_error (" top-level @include directive must be terminated by ';'" );
48
49
}
49
50
else if (peek< if_directive >()) {
50
51
root << parse_if_directive (Node (), Node::none);
@@ -138,7 +139,7 @@ namespace Sass {
138
139
139
140
Node Document::parse_mixin_definition ()
140
141
{
141
- lex< mixin >() || lex< exactly<' =' > >();
142
+ lex< mixin >() /* || lex< exactly<'='> >() */ ;
142
143
if (!lex< identifier >()) throw_syntax_error (" invalid name in @mixin directive" );
143
144
Node name (context.new_Node (Node::identifier, path, line, lexed));
144
145
Node params (parse_parameters ());
@@ -210,14 +211,21 @@ namespace Sass {
210
211
return var;
211
212
}
212
213
213
- Node Document::parse_mixin_call ()
214
+ Node Document::parse_mixin_call (Node::Type inside_of )
214
215
{
215
- lex< include >() || lex< exactly<' +' > >();
216
+ lex< include >() /* || lex< exactly<'+'> >() */ ;
216
217
if (!lex< identifier >()) throw_syntax_error (" invalid name in @include directive" );
217
218
Node name (context.new_Node (Node::identifier, path, line, lexed));
218
219
Node args (parse_arguments ());
219
- Node the_call (context.new_Node (Node::mixin_call, path, line, 2 ));
220
+ Node content;
221
+ bool has_content = false ;
222
+ if (peek< exactly<' {' > >()) {
223
+ content = parse_block (Node (), inside_of);
224
+ has_content = true ;
225
+ }
226
+ Node the_call (context.new_Node (Node::mixin_call, path, line, has_content ? 3 : 2 ));
220
227
the_call << name << args;
228
+ if (has_content) the_call << content;
221
229
return the_call;
222
230
}
223
231
@@ -596,16 +604,25 @@ namespace Sass {
596
604
block << parse_mixin_call ();
597
605
semicolon = true ;
598
606
}
607
+ else if (peek< content >(position)) {
608
+ if (inside_of != Node::mixin) {
609
+ throw_syntax_error (" @content may only be used within a mixin" );
610
+ }
611
+ block << context.new_Node (Node::mixin_content, path, line, Token::make ()); // just a stub
612
+ semicolon = true ;
613
+ }
599
614
else if (peek< sequence< identifier, optional_spaces, exactly<' :' >, optional_spaces, exactly<' {' > > >(position)) {
600
615
block << parse_propset ();
601
616
}
602
617
else if ((lookahead_result = lookahead_for_selector (position)).found ) {
603
618
block << parse_ruleset (lookahead_result, inside_of);
604
619
}
620
+ /*
605
621
else if (peek< exactly<'+'> >()) {
606
622
block << parse_mixin_call();
607
623
semicolon = true;
608
624
}
625
+ */
609
626
else if (lex< extend >()) {
610
627
Node request (context.new_Node (Node::extend_directive, path, line, 1 ));
611
628
Selector_Lookahead lookahead = lookahead_for_extension_target (position);
0 commit comments