Exemple #1
0
// SetImporter enables custom importer in libsass
func (ctx *Context) SetImporter(opts *C.struct_Sass_Options) {

	imps := C.sass_make_importer_list(1)
	hdr := reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(imps)),
		Len:  1, Cap: 1,
	}
	goimps := *(*[]C.Sass_Importer_Entry)(unsafe.Pointer(&hdr))
	p := C.SassImporter
	imp := C.sass_make_importer(
		C.Sass_Importer_Fn(p),
		C.double(0),
		unsafe.Pointer(ctx))
	goimps[0] = imp
	C.sass_option_set_c_importers(opts, imps)
}
Exemple #2
0
// BindImporter attaches a custom importer Go function to an import in Sass
func BindImporter(opts SassOptions, entries []ImportEntry) int {

	idx := globalImports.Set(entries)
	ptr := unsafe.Pointer(idx)

	imper := C.sass_make_importer(
		C.Sass_Importer_Fn(C.SassImporterHandler),
		C.double(0),
		ptr,
	)
	impers := C.sass_make_importer_list(1)
	C.sass_importer_set_list_entry(impers, 0, imper)

	C.sass_option_set_c_importers(
		(*C.struct_Sass_Options)(unsafe.Pointer(opts)),
		impers,
	)
	return *idx
}
Exemple #3
0
func SassOptionSetCImporters(goopts SassOptions, golst SassImporterList) {
	C.sass_option_set_c_importers(goopts, golst)
}