io.bit3.jsass.importer.JsassCustomHeaderImporter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsass Show documentation
Show all versions of jsass Show documentation
SASS compiler using libsass.
package io.bit3.jsass.importer;
import io.bit3.jsass.context.ImportStack;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
public class JsassCustomHeaderImporter implements Importer {
private final ImportStack importStack;
public JsassCustomHeaderImporter(ImportStack importStack) {
this.importStack = importStack;
}
@Override
public Collection apply(String url, Import previous) {
List list = new LinkedList<>();
list.add(createCustomHeaderImport(previous));
return list;
}
private Import createCustomHeaderImport(Import previous) {
int id = importStack.register(previous);
StringBuilder source = new StringBuilder();
// $jsass-void: jsass_import_stack_push() !global;
source.append(
String.format(
"$jsass-void: jsass_import_stack_push(%d) !global;%n",
id
)
);
try {
return new Import(
new URI(previous.getAbsoluteUri() + "/JSASS_CUSTOM.scss"),
new URI(previous.getAbsoluteUri() + "/JSASS_CUSTOM.scss"),
source.toString()
);
} catch (URISyntaxException e) {
throw new ImportException(e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy