Magnolia 5.4 reached end of life on November 15, 2018. This branch is no longer supported, see End-of-life policy.
...
New Web technologies such as Syntactically Awesome Style Sheets (Sass) and Less have largely replaced the need to do FreeMarker pre-processing for CSS files. You can now accomplish the same with a dedicated CSS pre-processor. We recommend that you start using such new technologies. Magnolia provides the /resources
path (without dot) as a legacy option to support older projects.
The Processed Resources app is configured in /modules/processed-resources-app
.
Advanced Tables - Table Plus | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
|
When a resource (CSS or JavaScript) is "processed" its content is interpreted as a FreeMarker template. You can use FreeMarker constants, variables and expressions inside the resource text. Magnolia evaluates them before serving the resources to the client.
Go to Web Dev > Processed Resources to open the app.
You can process different types of files. Choose a template that matches the file type:
/resources
pathUse the /resources
path (without dot) to load processed resources.
...
When you reference a resource with the /resources
path, the resource is not loaded by
Javadoc | ||
---|---|---|
|
When building large sites, authors often face a maintainability challenge. In such websites, the size of the CSS is quite large and a lot of information may be repeated in multiple places. For example, maintaining a coherent color scheme throughout a document implies reusing a few color values at numerous positions in the CSS files. Altering the scheme, whether tweaking a single color or completely rewriting it, therefore becomes a complex task requiring precision, as a single find and replace often isn't enough. – Mozilla Developer Network: Using CSS variables
...
Code Block | ||
---|---|---|
| ||
p { font-family: Verdana, sans-serif; font-size: 11px; color: #ff0099; } |
Merging several JavaScript files into one file makes sense if you load the same JavaScript everywhere. Consider creating packages of JavaScript files that always go together:
...
Processing is not recursive. This means, FreeMarker expressions are only evaluated in the parent node, not in child nodes.
Third-party JavaScript libraries get versioned frequently. You may want the latest version of a library in your project but don't want to keep updating references in all template scripts every time the resource file name changes. Or you may want minified and pretty-print versions of the same JavaScript with friendly file names.
...
When the library is updated you only need to update the reference, no need to touch the templates.
You can implement a custom model class and access the model's methods from inside a CSS or JavaScript document. In the model class you can use any Java logic or Magnolia functionality.
...