Sass_Import_List custom_importer(const char* cur_path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) { // get the cookie from importer descriptor void* cookie = sass_importer_get_cookie(cb); // create a list to hold our import entries Sass_Import_List incs = sass_make_import_list(1); // create our only import entry (route path back) incs[0] = sass_make_import_entry(cur_path, 0, 0); // return imports return incs; }
Sass_Import_List sass_importer(const char* cur_path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) { void* cookie = sass_importer_get_cookie(cb); struct Sass_Import* previous = sass_compiler_get_last_import(comp); const char* prev_path = sass_import_get_imp_path(previous); CustomImporterBridge& bridge = *(static_cast<CustomImporterBridge*>(cookie)); std::vector<void*> argv; argv.push_back((void*)cur_path); argv.push_back((void*)prev_path); return bridge(argv); }
// create a custom header to define to variables Sass_Import_List custom_header(const char* cur_path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) { // get the cookie from importer descriptor void* cookie = sass_importer_get_cookie(cb); // create a list to hold our import entries Sass_Import_List incs = sass_make_import_list(1); // create our only import entry (must make copy) incs[0] = sass_make_import_entry("[math]", strdup( "$E: 2.718281828459045235360287471352 !global;\n" "$PI: 3.141592653589793238462643383275 !global;\n" "$TAU: 6.283185307179586476925286766559 !global;\n" ), 0); // return imports return incs; }