public class Generator extends Object
A subclass can be created to override resolve(String) to change the way SASS files are
resolved (The default is to use the classpath). Also warn(String) and debug(String) can be
overridden to process messages which are generated while processing the code.
The resulting css code can be obtained by calling the toString() method.
| Modifier and Type | Field and Description |
|---|---|
protected File |
baseDir |
protected Map<String,Section> |
extensibleSections |
protected Set<String> |
importedSheets |
protected Map<String,Section> |
mediaQueries |
protected Map<String,Mixin> |
mixins |
protected Scope |
scope |
protected List<Section> |
sections |
| Constructor and Description |
|---|
Generator()
Generates a new Generator without a directory used for lookups.
|
Generator(File baseDir)
Generates a new Generator using the given directory for lookups.
|
| Modifier and Type | Method and Description |
|---|---|
void |
compile()
Compiles the parsed sources.
|
protected void |
compileMixins(Section section) |
void |
debug(String message)
Contains a message which might be helpful in development systems but are generally not of great
interest in production systems.
|
Expression |
evaluateFunction(FunctionCall call)
Evaluates the given function.
|
void |
generate(Output out)
Generates the final output into the given parameter.
|
void |
importStylesheet(String sheet)
Instructs the generator to include a scss file.
|
void |
importStylesheet(Stylesheet sheet)
Imports an already parsed stylesheet.
|
protected Stylesheet |
resolve(String sheet)
Resolves a given name into a template.
|
protected InputStream |
resolveIntoStream(String sheet)
Resolves the given file name into an
InputStream |
String |
toString() |
void |
warn(String message)
Called to signal a warning, like an invalid operation or parse errors in a source file.
|
public Generator()
This generator will resolve all imports using the classpath.
public Generator(File baseDir)
This generator will resolve all imports using the given directory or the classpath.
baseDir - the directory with contains the importspublic void warn(String message)
By default all messages are discarded.
message - the message which is reportedpublic void debug(String message)
message - the message which is reportedprotected Stylesheet resolve(String sheet)
By default the classloader is used to resolve the template. Also .scss or _ are added as post-/prefix if required.
sheet - the name of the file to resolveprotected InputStream resolveIntoStream(String sheet) throws IOException
InputStreamsheet - the file to resolve (already cleaned up by replacing \ with / and appending .scss if necessary).IOException - in case of an error while resolving or reading the contentspublic void importStylesheet(String sheet)
sheet - the scss file to load.public void importStylesheet(Stylesheet sheet)
sheet - the stylesheet to importpublic void compile()
This will evaluate all @mixin and @extends statements and evaluate all expressions. Needs to be called before
the sources are retrieved via toString().
protected void compileMixins(Section section)
public void generate(Output out) throws IOException
out - the target for the generated outputIOException - in case of an io error in the underlying writerpublic Expression evaluateFunction(FunctionCall call)
Can be overridden by subclasses. If no matching function is found, the raw sources are output to handle
url('..') etc.
call - the function to evaluateCopyright © 2016. All rights reserved.