DomUI supports Sass in SCSS format out of the box (since 2.0). The new 2.0 stylesheet (winter) is a scss stylesheet. These stylesheets are compiled on-the-fly by the DomUI server code, so changes made to the stylesheets take effect immediately.
Parameter support
You can pass parameters to scss style sheets by adding them to the URL for the style sheet. These parameters will be inserted into a "virtual" scss file called "_parameters.scss" which can be included in your scss stylesheet.
...
SASS uses variables and has quite advanced control structures. In DomUI it is possible to pass variables from "outside" the stylesheet into it. This allows you to control parts of the stylesheet's content depending on these variables.
To use the variables passed from the DomUI server the stylesheet must use
Code Block |
---|
@import "_parameters" |
This fixed name is not a real file (even though it might exist on the file system somewhere) but its content are generated by the DomUI server on the fly, and it contains variable assignments controlled by the framework.
There are two ways to control what variables are present in that file: URL parameters and session parameters.
Variables from URL parameters
The URL for the scss stylesheet can contain URL parameters. These parameters will be converted to SASS variables using the following mechanism:
- Any URL parameter whose name ends in $ is assumed to be a string variable, and the string value of the parameter will be added as a string to the generated _parameter.scss file. For example, if you add:
&header$=bg1.png
the parameter file will contain
$header="bg1.png";
i.e. the dollar sign is removed from the name, and the parameter value is quoted. - Any other parameter will be added verbatim, i.e. if you add:
&xmas=true
you will get the following inside the parameter file:
$xmas=true;
When creating the URL you need to take care of proper URL escaping of the values and names for the URL inside the HTML generated. This means that the dollar sign needs to be escaped as %24, and any oddities in the values need to be escaped like that too.
Caching and parameters
Stylesheets are cached inside the server for performance. Adding parameters means that each set of parameters requires a new sass compile and a new entry in the cache, so don't do things like adding a unique parameter per user.
...
The "key" for a cached stylesheet is the complete URL including all parameters and their values.
Implementation
The Sass stylesheets are handled by SassPartFactory: a buffered Part factory. This factory recognizes both .scss and .sass files. Since this is a buffered part factory all scss files compiled through it are cached in memory.Internals
The actual compilation is done by asking the SassCompilerFactory for a compiler. New compiler implementations can be built and registered there. We currently have two implementations:
...