How to call Font awesome assets
<template:addResources type="css" resources="all.min.css"/>
How to get the prefix
This version allows getting the prefix (fab|far|fas) from an icon using a function.
First, you will need to add a Maven dependency to your module
<dependency>
<groupId>org.jahia.modules</groupId>
<artifactId>font-awesome</artifactId>
<version>[6.0,6.2)</version>
<scope>provided</scope>
</dependency>
Also, in your pom.xml, you will need to add the package com.jahia.module.fontawesome
in the list of the Import-Package
of your maven-bundle-plugin
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Import-Package>com.jahia.module.fontawesome,${jahia.plugin.projectPackageImport},*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
Then declare the taglib and use the fa:getPrefix function
<%@ taglib prefix="fa" uri="http://font-awesome.com/taglibs" %>
${fa:getPrefix('fa-ban')}
This will return fas
because the icon ban
is located in the solid font (fas).
Please check the ChangeLog at https://github.com/FortAwesome/Font-Awesome/blob/master/CHANGELOG.md
Are you a Font awesome 4 user
If yes, you should seriously read the related doc on the font awesome website https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4, but you can still try to use the deprecated font-awesome.css file or simply add ad a v4-shims.min.css to keep compatibility.
<template:addResources type="css" resources="all.min.css"/>
<template:addResources type="css" resources="v4-shims.min.css"/>