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
3737754b
Commit
3737754b
authored
Jan 12, 2014
by
Steven Luscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented the imagePath option, for use with the image-url() function.
parent
1c3c5e63
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
24 deletions
+31
-24
binding.cpp
binding.cpp
+22
-17
sass.js
sass.js
+9
-7
No files found.
binding.cpp
View file @
3737754b
...
@@ -23,14 +23,19 @@ void WorkOnContext(uv_work_t* req) {
...
@@ -23,14 +23,19 @@ void WorkOnContext(uv_work_t* req) {
void
extractOptions
(
_NAN_METHOD_ARGS
,
void
*
cptr
,
sass_context_wrapper
*
ctx_w
,
bool
isFile
)
{
void
extractOptions
(
_NAN_METHOD_ARGS
,
void
*
cptr
,
sass_context_wrapper
*
ctx_w
,
bool
isFile
)
{
char
*
source
;
char
*
source
;
char
*
pathOrData
;
char
*
pathOrData
;
char
*
imagePath
;
int
output_style
;
int
output_style
;
int
source_comments
;
int
source_comments
;
String
::
AsciiValue
astr
(
args
[
0
]);
String
::
AsciiValue
astr
(
args
[
0
]);
String
::
AsciiValue
bstr
(
args
[
1
]);
imagePath
=
new
char
[
strlen
(
*
bstr
)
+
1
];
strcpy
(
imagePath
,
*
bstr
);
if
(
ctx_w
)
{
if
(
ctx_w
)
{
// async (callback) style
// async (callback) style
Local
<
Function
>
callback
=
Local
<
Function
>::
Cast
(
args
[
1
]);
Local
<
Function
>
callback
=
Local
<
Function
>::
Cast
(
args
[
2
]);
Local
<
Function
>
errorCallback
=
Local
<
Function
>::
Cast
(
args
[
2
]);
Local
<
Function
>
errorCallback
=
Local
<
Function
>::
Cast
(
args
[
3
]);
if
(
isFile
)
{
if
(
isFile
)
{
ctx_w
->
fctx
=
(
sass_file_context
*
)
cptr
;
ctx_w
->
fctx
=
(
sass_file_context
*
)
cptr
;
}
else
{
}
else
{
...
@@ -39,18 +44,18 @@ void extractOptions(_NAN_METHOD_ARGS, void* cptr, sass_context_wrapper* ctx_w, b
...
@@ -39,18 +44,18 @@ void extractOptions(_NAN_METHOD_ARGS, void* cptr, sass_context_wrapper* ctx_w, b
ctx_w
->
request
.
data
=
ctx_w
;
ctx_w
->
request
.
data
=
ctx_w
;
ctx_w
->
callback
=
new
NanCallback
(
callback
);
ctx_w
->
callback
=
new
NanCallback
(
callback
);
ctx_w
->
errorCallback
=
new
NanCallback
(
errorCallback
);
ctx_w
->
errorCallback
=
new
NanCallback
(
errorCallback
);
output_style
=
args
[
4
]
->
Int32Value
();
output_style
=
args
[
5
]
->
Int32Value
();
source_comments
=
args
[
5
]
->
Int32Value
();
source_comments
=
args
[
6
]
->
Int32Value
();
String
::
AsciiValue
bstr
(
args
[
3
]);
String
::
AsciiValue
cstr
(
args
[
4
]);
pathOrData
=
new
char
[
strlen
(
*
b
str
)
+
1
];
pathOrData
=
new
char
[
strlen
(
*
c
str
)
+
1
];
strcpy
(
pathOrData
,
*
b
str
);
strcpy
(
pathOrData
,
*
c
str
);
}
else
{
}
else
{
// synchronous style
// synchronous style
output_style
=
args
[
2
]
->
Int32Value
();
output_style
=
args
[
3
]
->
Int32Value
();
source_comments
=
args
[
3
]
->
Int32Value
();
source_comments
=
args
[
4
]
->
Int32Value
();
String
::
AsciiValue
bstr
(
args
[
1
]);
String
::
AsciiValue
cstr
(
args
[
2
]);
pathOrData
=
new
char
[
strlen
(
*
b
str
)
+
1
];
pathOrData
=
new
char
[
strlen
(
*
c
str
)
+
1
];
strcpy
(
pathOrData
,
*
b
str
);
strcpy
(
pathOrData
,
*
c
str
);
}
}
if
(
isFile
)
{
if
(
isFile
)
{
...
@@ -58,21 +63,21 @@ void extractOptions(_NAN_METHOD_ARGS, void* cptr, sass_context_wrapper* ctx_w, b
...
@@ -58,21 +63,21 @@ void extractOptions(_NAN_METHOD_ARGS, void* cptr, sass_context_wrapper* ctx_w, b
char
*
filename
=
new
char
[
strlen
(
*
astr
)
+
1
];
char
*
filename
=
new
char
[
strlen
(
*
astr
)
+
1
];
strcpy
(
filename
,
*
astr
);
strcpy
(
filename
,
*
astr
);
ctx
->
input_path
=
filename
;
ctx
->
input_path
=
filename
;
ctx
->
options
.
image_path
=
new
char
[
0
]
;
ctx
->
options
.
image_path
=
imagePath
;
ctx
->
options
.
output_style
=
output_style
;
ctx
->
options
.
output_style
=
output_style
;
ctx
->
options
.
source_comments
=
source_comments
;
ctx
->
options
.
source_comments
=
source_comments
;
ctx
->
options
.
include_paths
=
pathOrData
;
ctx
->
options
.
include_paths
=
pathOrData
;
if
(
source_comments
==
SASS_SOURCE_COMMENTS_MAP
)
{
if
(
source_comments
==
SASS_SOURCE_COMMENTS_MAP
)
{
String
::
AsciiValue
cstr
(
args
[
6
]);
String
::
AsciiValue
dstr
(
args
[
7
]);
ctx
->
source_map_file
=
new
char
[
strlen
(
*
c
str
)
+
1
];
ctx
->
source_map_file
=
new
char
[
strlen
(
*
d
str
)
+
1
];
strcpy
(
ctx
->
source_map_file
,
*
c
str
);
strcpy
(
ctx
->
source_map_file
,
*
d
str
);
}
}
}
else
{
}
else
{
sass_context
*
ctx
=
(
sass_context
*
)
cptr
;
sass_context
*
ctx
=
(
sass_context
*
)
cptr
;
source
=
new
char
[
strlen
(
*
astr
)
+
1
];
source
=
new
char
[
strlen
(
*
astr
)
+
1
];
strcpy
(
source
,
*
astr
);
strcpy
(
source
,
*
astr
);
ctx
->
source_string
=
source
;
ctx
->
source_string
=
source
;
ctx
->
options
.
image_path
=
new
char
[
0
]
;
ctx
->
options
.
image_path
=
imagePath
;
ctx
->
options
.
output_style
=
output_style
;
ctx
->
options
.
output_style
=
output_style
;
ctx
->
options
.
source_comments
=
source_comments
;
ctx
->
options
.
source_comments
=
source_comments
;
ctx
->
options
.
include_paths
=
pathOrData
;
ctx
->
options
.
include_paths
=
pathOrData
;
...
...
sass.js
View file @
3737754b
...
@@ -34,14 +34,16 @@ var SASS_SOURCE_COMMENTS = {
...
@@ -34,14 +34,16 @@ var SASS_SOURCE_COMMENTS = {
};
};
var
prepareOptions
=
function
(
options
)
{
var
prepareOptions
=
function
(
options
)
{
var
paths
,
style
,
comments
;
var
paths
,
imagePath
,
style
,
comments
;
options
=
typeof
options
!==
'object'
?
{}
:
options
;
options
=
typeof
options
!==
'object'
?
{}
:
options
;
paths
=
options
.
include_paths
||
options
.
includePaths
||
[];
paths
=
options
.
include_paths
||
options
.
includePaths
||
[];
imagePath
=
options
.
image_path
||
options
.
imagePath
||
''
;
style
=
SASS_OUTPUT_STYLE
[
options
.
output_style
||
options
.
outputStyle
]
||
0
;
style
=
SASS_OUTPUT_STYLE
[
options
.
output_style
||
options
.
outputStyle
]
||
0
;
comments
=
SASS_SOURCE_COMMENTS
[
options
.
source_comments
||
options
.
sourceComments
]
||
0
;
comments
=
SASS_SOURCE_COMMENTS
[
options
.
source_comments
||
options
.
sourceComments
]
||
0
;
return
{
return
{
paths
:
paths
,
paths
:
paths
,
imagePath
:
imagePath
,
style
:
style
,
style
:
style
,
comments
:
comments
comments
:
comments
};
};
...
@@ -55,12 +57,12 @@ var deprecatedRender = function(css, callback, options) {
...
@@ -55,12 +57,12 @@ var deprecatedRender = function(css, callback, options) {
var
oldCallback
=
function
(
css
)
{
var
oldCallback
=
function
(
css
)
{
callback
(
null
,
css
);
callback
(
null
,
css
);
};
};
return
binding
.
render
(
css
,
oldCallback
,
errCallback
,
options
.
paths
.
join
(
':'
),
options
.
style
,
options
.
comments
);
return
binding
.
render
(
css
,
o
ptions
.
imagePath
,
o
ldCallback
,
errCallback
,
options
.
paths
.
join
(
':'
),
options
.
style
,
options
.
comments
);
};
};
var
deprecatedRenderSync
=
function
(
css
,
options
)
{
var
deprecatedRenderSync
=
function
(
css
,
options
)
{
options
=
prepareOptions
(
options
);
options
=
prepareOptions
(
options
);
return
binding
.
renderSync
(
css
,
options
.
paths
.
join
(
':'
),
options
.
style
,
options
.
comments
);
return
binding
.
renderSync
(
css
,
options
.
imagePath
,
options
.
paths
.
join
(
':'
),
options
.
style
,
options
.
comments
);
};
};
exports
.
render
=
function
(
options
)
{
exports
.
render
=
function
(
options
)
{
...
@@ -74,11 +76,11 @@ exports.render = function(options) {
...
@@ -74,11 +76,11 @@ exports.render = function(options) {
options
.
error
=
options
.
error
||
function
(){};
options
.
error
=
options
.
error
||
function
(){};
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
return
binding
.
renderFile
(
options
.
file
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
,
newOptions
.
comments
,
options
.
sourceMap
);
return
binding
.
renderFile
(
options
.
file
,
newOptions
.
imagePath
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
,
newOptions
.
comments
,
options
.
sourceMap
);
}
}
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
return
binding
.
render
(
options
.
data
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
);
return
binding
.
render
(
options
.
data
,
newOptions
.
imagePath
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
);
};
};
exports
.
renderSync
=
function
(
options
)
{
exports
.
renderSync
=
function
(
options
)
{
...
@@ -91,11 +93,11 @@ exports.renderSync = function(options) {
...
@@ -91,11 +93,11 @@ exports.renderSync = function(options) {
newOptions
=
prepareOptions
(
options
);
newOptions
=
prepareOptions
(
options
);
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
return
binding
.
renderFileSync
(
options
.
file
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
,
newOptions
.
comments
);
return
binding
.
renderFileSync
(
options
.
file
,
newOptions
.
imagePath
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
,
newOptions
.
comments
);
}
}
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
return
binding
.
renderSync
(
options
.
data
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
);
return
binding
.
renderSync
(
options
.
data
,
newOptions
.
imagePath
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
);
};
};
exports
.
middleware
=
require
(
'./lib/middleware'
);
exports
.
middleware
=
require
(
'./lib/middleware'
);
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