Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: DOCU-2700


...

alignright
classmenu

The Processed Resources App enables processing of resource files. 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.

Note
iconfalse

Resource processing was removed from the standard Resources module and the Processed Resources app module brings back this functionality for users who rely on it. Note that this module is not part of the preconfigured Magnolia bundles and needs to be installed separately. 

...

  • Processed CSS, HTML and JS: These templates interpret the resource as a Freemarker template before serving it to the client. Use the templates to post-process CSS, HTML or JavaScript. You can use any FreeMarker constants, variables and expressions in the file text. You can also access Magnolia content and configuration using cmsfn templating functions.
  • Non-processed CSS, HTML, JS and YAML: These templates do not process the resource. The resource is treated as a static file and served to the client as such. However, you get an editor that provides syntax highlighting and search for the designated file type.
     
  • Reference: Create a reference to another resource in the same workspace. This is useful for providing aliases.
  • Binary: Use this template for non-editorial binary resources that change rarely such as logos, icons and fonts.

...

Code Block
languagexml
<link rel="stylesheet" href="${ctx.contextPath}/resources/my-module/css/all-styles.css">

The /resources path is mapped to the resources workspace in /server/URI2RepositoryMapping/mappings/resources using URI to repository mapping. This ensures that resources are loaded correctly also in projects that are built on earlier versions of Magnolia which you may want to run on Magnolia 5.4.

(warning) When you reference a resource with the /resources path, the resource is not loaded by 

Javadoc
0info.magnolia.module.resources.ResourcesServlet
 and the three origins are not checked.

Use cases

...

In the parent resource, use a FreeMarker list directive to iterate through the children and access their content:

...

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.

...