Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
fb430b74
Commit
fb430b74
authored
Sep 26, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementing the 'index' built-in.
parent
20443772
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
context.cpp
context.cpp
+1
-0
functions.cpp
functions.cpp
+19
-0
functions.hpp
functions.hpp
+3
-0
No files found.
context.cpp
View file @
fb430b74
...
...
@@ -150,6 +150,7 @@ namespace Sass {
// List Functions
register_function
(
length_sig
,
length
);
register_function
(
nth_sig
,
nth
);
register_function
(
index_sig
,
index
);
register_function
(
join_sig
,
join
);
register_function
(
append_sig
,
append
);
register_overload_stub
(
"compact"
);
...
...
functions.cpp
View file @
fb430b74
...
...
@@ -935,6 +935,25 @@ namespace Sass {
return
l
[
n
-
1
];
}
extern
Signature
index_sig
=
"index($list, $value)"
;
Node
index
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
lst
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
val
(
bindings
[
parameter_names
[
1
].
token
()]);
// if $list isn't a list, wrap it in a singleton list
Node
::
Type
lst_type
=
lst
.
type
();
if
(
lst_type
!=
Node
::
space_list
&&
lst_type
!=
Node
::
comma_list
&&
lst_type
!=
Node
::
nil
)
{
lst
=
(
new_Node
(
Node
::
space_list
,
path
,
line
,
1
)
<<
lst
);
}
if
(
lst_type
==
Node
::
nil
)
return
new_Node
(
Node
::
boolean
,
path
,
line
,
false
);
for
(
size_t
i
=
0
,
S
=
lst
.
size
();
i
<
S
;
++
i
)
{
if
(
lst
[
i
]
==
val
)
return
new_Node
(
path
,
line
,
i
+
1
);
}
return
new_Node
(
Node
::
boolean
,
path
,
line
,
false
);
}
extern
Signature
join_sig
=
"join($list1, $list2, $separator: auto)"
;
Node
join
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
// if the args aren't lists, turn them into singleton lists
...
...
functions.hpp
View file @
fb430b74
...
...
@@ -187,6 +187,9 @@ namespace Sass {
extern
Signature
nth_sig
;
Node
nth
(
const
Node
,
Environment
&
,
Node_Factory
&
,
string
&
path
,
size_t
line
);
extern
Signature
index_sig
;
Node
index
(
const
Node
,
Environment
&
,
Node_Factory
&
,
string
&
path
,
size_t
line
);
extern
Signature
join_sig
;
Node
join
(
const
Node
,
Environment
&
,
Node_Factory
&
,
string
&
path
,
size_t
line
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment