Skip to content

Commit 2c8c2ab

Browse files
author
Aaron Leung
committed
Allowing the Document constructor to read partials (i.e., the user can say "@import 'partial.scss';" when the file is named "_partial.scss".
1 parent 086771a commit 2c8c2ab

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

document.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ namespace Sass {
2929
Document Document::make_from_file(Context& ctx, string path)
3030
{
3131
std::FILE *f;
32-
f = std::fopen(path.c_str(), "rb");
33-
if (!f) throw path;
32+
const char* path_str = path.c_str();
33+
f = std::fopen(path_str, "rb");
34+
if (!f) {
35+
const char* file_name_str = Prelexer::folders(path_str);
36+
f = std::fopen((Token::make(path_str, file_name_str).to_string() +
37+
"_" +
38+
Token::make(file_name_str).to_string()).c_str(), "rb");
39+
if (!f) throw path;
40+
}
3441
if (std::fseek(f, 0, SEEK_END)) throw path;
3542
int status = std::ftell(f);
3643
if (status < 0) throw path;

0 commit comments

Comments
 (0)