Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 3f5a8ab

Browse files
author
Aaron Leung
committed
Allowing namespaced properties to have interpolants.
1 parent cb7d066 commit 3f5a8ab

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

constants.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace Sass {
8484
extern const char rbrace[] = "}";
8585
extern const char rparen[] = ")";
8686
extern const char sign_chars[] = "-+";
87+
extern const char hyphen[] = "-";
8788

8889
// type names
8990
extern const char numeric_name[] = "numeric value";

constants.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace Sass {
8484
extern const char rbrace[];
8585
extern const char rparen[];
8686
extern const char sign_chars[];
87+
extern const char hyphen[];
8788

8889
// type names
8990
extern const char numeric_name[];

document_parser.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Sass {
3636
root << parse_assignment();
3737
if (!lex< exactly<';'> >()) throw_syntax_error("top-level variable binding must be terminated by ';'");
3838
}
39-
else if (peek< sequence< identifier, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
39+
else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
4040
root << parse_propset();
4141
}
4242
else if ((lookahead_result = lookahead_for_selector(position)).found) {
@@ -296,16 +296,22 @@ namespace Sass {
296296
if (lex< default_flag >()) assn << context.new_Node(Node::none, path, line, 0);
297297
return assn;
298298
}
299-
299+
300300
Node Document::parse_propset()
301301
{
302-
lex< identifier >();
303-
Node property_segment(context.new_Node(Node::identifier, path, line, lexed));
302+
Node property_segment;
303+
if (peek< sequence< optional< exactly<'*'> >, identifier_schema > >()) {
304+
property_segment = parse_identifier_schema();
305+
}
306+
else {
307+
lex< sequence< optional< exactly<'*'> >, identifier > >();
308+
property_segment = context.new_Node(Node::identifier, path, line, lexed);
309+
}
304310
lex< exactly<':'> >();
305311
lex< exactly<'{'> >();
306312
Node block(context.new_Node(Node::block, path, line, 1));
307313
while (!lex< exactly<'}'> >()) {
308-
if (peek< sequence< identifier, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
314+
if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
309315
block << parse_propset();
310316
}
311317
else {
@@ -611,7 +617,7 @@ namespace Sass {
611617
block << context.new_Node(Node::mixin_content, path, line, 0); // just an expansion stub
612618
semicolon = true;
613619
}
614-
else if (peek< sequence< identifier, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
620+
else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
615621
block << parse_propset();
616622
}
617623
else if ((lookahead_result = lookahead_for_selector(position)).found) {

eval_apply.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,26 @@ namespace Sass {
6565

6666
case Node::propset: {
6767
// TO DO: perform the property expansion here, rather than in the emitter (also requires the parser to allow interpolants in the property names)
68+
expr[0] = eval(expr[0], prefix, env, f_env, new_Node, ctx, bt);
6869
expand(expr[1], prefix, env, f_env, new_Node, ctx, bt, false, content);
70+
71+
// Node block(expr[1]);
72+
// for (size_t i = 0, S = block.size(); i < S; ++i) {
73+
// Node stm(block[i]);
74+
// switch (stm.type())
75+
// {
76+
// case Node::propset:
77+
// case Node::mixin_call:
78+
// case Node::if_directive:
79+
// case Node::for_through_directive:
80+
// case Node::for_to_directive:
81+
// case Node::each_directive:
82+
// case Node::while_directive:
83+
// case Node::warning: {
84+
// expand(stm, prefix, env, f_env, new_Node, ctx, bt, false, content);
85+
// } break;
86+
// }
87+
// }
6988
} break;
7089

7190
case Node::ruleset: {

node_emitters.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,11 @@ namespace Sass {
721721
new_prefix += "\n";
722722
new_prefix += string(2*depth, ' ');
723723
}
724-
new_prefix += at(0).token().to_string();
724+
new_prefix += at(0).to_string();
725725
}
726726
else {
727727
new_prefix += "-";
728-
new_prefix += at(0).token().to_string();
728+
new_prefix += at(0).to_string();
729729
// has_prefix = true;
730730
}
731731
Node rules(at(1));
@@ -735,9 +735,11 @@ namespace Sass {
735735
}
736736
else {
737737
buf << new_prefix;
738-
if (rules[i][0].token().to_string() != "") buf << '-';
738+
if (rules[i][0].to_string() != "") buf << '-';
739739
if (!compressed) {
740+
buf << "[hey]";
740741
rules[i][0].emit_nested_css(buf, depth);
742+
buf << "[colon]";
741743
rules[i][1].emit_nested_css(buf, depth);
742744
}
743745
else {

0 commit comments

Comments
 (0)