Live edit freemarker templates in magnolia

Small little steps to render freemarker (FTL) templates in magnolia while still being able to edit them and not put them into the templates workspace

  1. Inside magnolia central goto /server/rendering/freemarker/templateLoaders
  2. Create a contentNode “fileSystem”
  3. On the newly created “fileSystem” node, create two properties:
    A “class” property with value “info.magnolia.freemarker.loaders.LazyFileTemplateLoader”
    A “basePath” property with value “path/to/your/templates”

Even though the system is now capable of loading the templates from the filesystem, it will first look on the classpath.

To change the order in which FTL files are retrieved we need to move the fileSystem node into the first position inside the /server/rendering/freemarker/templateLoaders:

  1. Select the fileSystem node, and click the Move Item action.
  2. Select the first childnode of /server/rendering/freemarker/templateLoaders (typically jcr) and select MOVE BEFORE.
  3. Open any ftl template, add some random code, observe that it reflects instantly. Make sure to remove the random code afterwards

Happy coding.

Be Sociable, Share!

Tags: , , ,

Leave a Comment

This blog is kept spam free by WP-SpamFree.