本文整理汇总了Java中io.bit3.jsass.Output类的典型用法代码示例。如果您正苦于以下问题:Java Output类的具体用法?Java Output怎么用?Java Output使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Output类属于io.bit3.jsass包,在下文中一共展示了Output类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cssFromSass
import io.bit3.jsass.Output; //导入依赖的package包/类
private File cssFromSass(File source) throws IOException
{
String sourceName = source.getName();
int lastDotIndex = sourceName.lastIndexOf(SASS_SUFFIX);
String cssName = sourceName.substring(0, lastDotIndex) + CSS_SUFFIX;
File cssFile = new File(source.getParentFile(), cssName);
//ONLY FROM CACHE IF WAS MODIFIED AFTER SASS FILE
if (cssFile.exists() && source.lastModified() <= cssFile.lastModified())
{
List<String> lines = IOUtils.readLines(new FileInputStream(cssFile));
if (lines != null && !lines.isEmpty())
{
return cssFile;
}
}
if (!cssFile.exists() && !cssFile.createNewFile())
{
LOG.log(Level.SEVERE, "Could not create: {0} to compile sass", cssFile.getAbsolutePath());
return null;
}
Compiler compiler = new Compiler();
Options options = new Options();//TODO: options
try
{
Output output = compiler.compileFile(source.toURI(), cssFile.toURI(), options);
IOUtils.copy(new StringReader(output.getCss()), new FileOutputStream(cssFile));
return cssFile;
}
catch (CompilationException ex)
{
LOG.log(Level.SEVERE, "Error compiling SASS: {0}", ex.getMessage());
return null;
}
}
示例2: compiler
import io.bit3.jsass.Output; //导入依赖的package包/类
@Override public void compiler(String rurl, Writer output, @Nonnull ParameterInfoImpl params, @Nonnull IResourceDependencyList rdl) throws Exception {
/*
* Define resolvers: these resolve "filenames" in the scss to resources in the webapp.
*/
String basePath;
int pos = rurl.lastIndexOf('/');
if(pos == -1) {
basePath = "";
} else {
basePath = rurl.substring(pos + 1);
}
JSassResolver jsr = new JSassResolver(params, basePath, rdl);
Import file = jsr.resolve(rurl, "");
if(null == file)
throw new ThingyNotFoundException("The sass/scss file " + rurl + " could not be found");
File out = File.createTempFile("sass-out-", ".css");
System.out.println("out " + out);
Options opt = new Options();
opt.setImporters(Collections.singletonList(jsr));
opt.setOutputStyle(OutputStyle.EXPANDED);
opt.setIndent("\t");
opt.setLinefeed("\n");
opt.setSourceMapEmbed(true);
opt.setSourceComments(false);
boolean isSass = rurl.toLowerCase().endsWith(".sass");
opt.setIsIndentedSyntaxSrc(isSass);
StringContext fc = new StringContext(file.getContents(), file.getImportUri(), out.toURI(), opt);
Compiler co = new Compiler();
Output res = co.compile(fc);
String css = res.getCss();
output.write(css);
out.delete();
jsr.close();
}
示例3: sassify
import io.bit3.jsass.Output; //导入依赖的package包/类
private static void sassify(File sassFile) {
final File outputFile = getOutputFile(sassFile, Suffix.CSS);
final URI inputURI = sassFile.toURI();
final URI outputURI = outputFile.toURI();
final Compiler compiler = new Compiler();
try {
final Output output = compiler.compileFile(inputURI, outputURI, new Options());
FileUtils.writeStringToFile(outputFile, output.getCss(), Default.ENCODING.toString());
logPreprocess(sassFile, outputFile);
} catch (CompilationException | IOException e) {
LOG.error("Failed to preprocess SASS file", e);
}
}
示例4: doDeploy
import io.bit3.jsass.Output; //导入依赖的package包/类
@Override
public void doDeploy(File root, String path, URL entry, MProperties config) {
File f = new File(root, path);
root = f.getParentFile();
root.mkdirs();
File out = new File(root, MFile.replaceSuffix(f.getName(), "css") );
try {
Output output = compiler.compileFile(f.toURI(), out.toURI(), options);
} catch (CompilationException e) {
log().e(f,e);
}
}
示例5: getCompiledStylesheet
import io.bit3.jsass.Output; //导入依赖的package包/类
@Override
// If checkCacheInvalidation is true and, before invocation, a cached value exists and is not up to date, we evict the cache entry.
@CacheEvict(value = "scssService.compiledStylesheets",
key = "T(fr.openwide.core.wicket.more.css.scss.service.ScssServiceImpl).getCacheKey(#scope, #path)",
beforeInvocation = true,
condition= "#checkCacheEntryUpToDate && !(caches.?[name=='scssService.compiledStylesheets'][0]?.get(T(fr.openwide.core.wicket.more.css.scss.service.ScssServiceImpl).getCacheKey(#scope, #path))?.get()?.isUpToDate() ?: false)"
)
// THEN, we check if a cached value exists. If it does, it is returned ; if not, the method is called.
@Cacheable(value = "scssService.compiledStylesheets",
key = "T(fr.openwide.core.wicket.more.css.scss.service.ScssServiceImpl).getCacheKey(#scope, #path)")
public ScssStylesheetInformation getCompiledStylesheet(Class<?> scope, String path, boolean checkCacheEntryUpToDate)
throws ServiceException {
String scssPath = getFullPath(scope, path);
try {
JSassScopeAwareImporter importer = new JSassScopeAwareImporter(SCOPES);
importer.addSourceUri(scssPath);
Compiler compiler = new Compiler();
Options options = new Options();
options.setOutputStyle(OutputStyle.EXPANDED);
options.setIndent("\t");
options.getImporters().add(importer);
ClassPathResource scssCpr = new ClassPathResource(scssPath);
Context fileContext = new StringContext(IOUtils.toString(scssCpr.getInputStream()), new URI("classpath", "/" + scssPath, null), null, options);
Output output = compiler.compile(fileContext);
// Write result
ScssStylesheetInformation compiledStylesheet = new ScssStylesheetInformation(scssPath, output.getCss());
for (String sourceUri : importer.getSourceUris()) {
ClassPathResource cpr = new ClassPathResource(sourceUri);
compiledStylesheet.addImportedStylesheet(new ScssStylesheetInformation(sourceUri, cpr.lastModified()));
}
return compiledStylesheet;
} catch (RuntimeException | IOException | URISyntaxException | CompilationException e) {
throw new ServiceException(String.format("Error compiling %1$s", scssPath), e);
}
}
示例6: process
import io.bit3.jsass.Output; //导入依赖的package包/类
@Override
public String process(final String filename, final String source, final Config conf, final ClassLoader loader)
throws Exception {
String syntax = get("syntax");
String importer = get("importer").toString().toUpperCase();
Function<String, URI> resolver;
if("FILE".equals(importer)) {
resolver = FS;
} else {
resolver = CP.apply(loader);
}
OutputStyle style = OutputStyle.valueOf(get("style").toString().toUpperCase());
Options options = new Options();
options.setIsIndentedSyntaxSrc("sass".equals(syntax));
options.getImporters().add(new SassImporter(syntax, resolver));
options.setOutputStyle(style);
options.setIndent(get("indent"));
options.setLinefeed(get("linefeed"));
options.setOmitSourceMapUrl(get("omitSourceMapUrl"));
options.setPrecision(get("precision"));
options.setSourceComments(get("sourceComments"));
String sourcemap = get("sourcemap");
if ("inline".equals(sourcemap)) {
options.setSourceMapEmbed(true);
} else if ("file".equals(sourcemap)) {
options.setSourceMapFile(URI.create(filename + ".map"));
}
try {
URI input = URI.create(filename);
StringContext ctx = new StringContext(source, input, null, options);
Output output = new Compiler().compile(ctx);
return filename.endsWith(".map") ? output.getSourceMap() : output.getCss();
} catch (CompilationException x) {
Matcher matcher = LOCATION.matcher(x.getErrorJson());
Map<String, Integer> location = new HashMap<>();
while (matcher.find()) {
location.put(matcher.group(1), Integer.parseInt(matcher.group(2)));
}
int line = location.getOrDefault("line", -1);
int column = location.getOrDefault("column", -1);
throw new AssetException(name(),
new AssetProblem(Optional.ofNullable(x.getErrorFile()).orElse(filename), line, column,
x.getErrorText(), null));
}
}