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
471a0759
Commit
471a0759
authored
Dec 21, 2014
by
Adeel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Importer: Ability to return value.
Feature suggested by @jhnns.
parent
9ec016f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
6 deletions
+78
-6
index.js
lib/index.js
+8
-2
api.js
test/api.js
+70
-4
No files found.
lib/index.js
View file @
471a0759
...
...
@@ -176,12 +176,18 @@ function getOptions(options) {
if
(
importer
)
{
options
.
importer
=
function
(
file
,
prev
,
key
)
{
importer
(
file
,
prev
,
function
(
data
)
{
var
done
=
function
(
data
)
{
binding
.
importedCallback
({
index
:
key
,
objectLiteral
:
data
});
});
};
var
result
=
importer
(
file
,
prev
,
done
);
if
(
result
)
{
done
(
result
);
}
};
}
...
...
test/api.js
View file @
471a0759
...
...
@@ -133,7 +133,7 @@ describe('api', function() {
});
});
it
(
'should override imports with custom importer with
data
'
,
function
(
done
)
{
it
(
'should override imports with custom importer with
"data" as input and uses callback
'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'include-files/index.scss'
),
'utf8'
);
sass
.
render
({
...
...
@@ -151,7 +151,7 @@ describe('api', function() {
});
});
it
(
'should override imports with custom importer with
file
'
,
function
(
done
)
{
it
(
'should override imports with custom importer with
"file" as input and uses callback
'
,
function
(
done
)
{
sass
.
render
({
file
:
fixture
(
'include-files/index.scss'
),
success
:
function
(
result
)
{
...
...
@@ -166,6 +166,40 @@ describe('api', function() {
}
});
});
it
(
'should override imports with custom importer with "data" as input and returns value'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'include-files/index.scss'
),
'utf8'
);
sass
.
render
({
data
:
src
,
success
:
function
(
result
)
{
assert
.
equal
(
result
.
css
.
trim
(),
'div {
\
n color: yellow; }
\
n
\
ndiv {
\
n color: yellow; }'
);
done
();
},
importer
:
function
(
url
,
prev
)
{
return
{
file
:
prev
+
url
,
contents
:
'div {color: yellow;}'
};
}
});
});
it
(
'should override imports with custom importer with "file" as input and returns value'
,
function
(
done
)
{
sass
.
render
({
file
:
fixture
(
'include-files/index.scss'
),
success
:
function
(
result
)
{
assert
.
equal
(
result
.
css
.
trim
(),
'div {
\
n color: yellow; }
\
n
\
ndiv {
\
n color: yellow; }'
);
done
();
},
importer
:
function
(
url
,
prev
)
{
return
{
file
:
prev
+
url
,
contents
:
'div {color: yellow;}'
};
}
});
});
});
describe
(
'.renderSync(options)'
,
function
()
{
...
...
@@ -206,7 +240,7 @@ describe('api', function() {
done
();
});
it
(
'should override imports with custom importer with
data
'
,
function
(
done
)
{
it
(
'should override imports with custom importer with
"data" as input and uses callback
'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'include-files/index.scss'
),
'utf8'
);
var
result
=
sass
.
renderSync
({
...
...
@@ -223,7 +257,7 @@ describe('api', function() {
done
();
});
it
(
'should override imports with custom importer with
file
'
,
function
(
done
)
{
it
(
'should override imports with custom importer with
"file" as input and uses callback
'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
file
:
fixture
(
'include-files/index.scss'
),
importer
:
function
(
url
,
prev
,
finish
)
{
...
...
@@ -237,6 +271,38 @@ describe('api', function() {
assert
.
equal
(
result
.
css
.
trim
(),
'div {
\
n color: yellow; }
\
n
\
ndiv {
\
n color: yellow; }'
);
done
();
});
it
(
'should override imports with custom importer with "data" as input and returns value'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'include-files/index.scss'
),
'utf8'
);
var
result
=
sass
.
renderSync
({
data
:
src
,
importer
:
function
(
url
,
prev
)
{
return
{
file
:
prev
+
url
,
contents
:
'div {color: yellow;}'
};
}
});
assert
.
equal
(
result
.
css
.
trim
(),
'div {
\
n color: yellow; }
\
n
\
ndiv {
\
n color: yellow; }'
);
done
();
});
it
(
'should override imports with custom importer with "file" as input and returns value'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
file
:
fixture
(
'include-files/index.scss'
),
importer
:
function
(
url
,
prev
)
{
return
{
file
:
prev
+
url
,
contents
:
'div {color: yellow;}'
};
}
});
assert
.
equal
(
result
.
css
.
trim
(),
'div {
\
n color: yellow; }
\
n
\
ndiv {
\
n color: yellow; }'
);
done
();
});
});
describe
(
'.render({stats: {}})'
,
function
()
{
...
...
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