Class LoadGoogleFontDirective
java.lang.Object
ch.tocco.nice2.templating.impl.freemarker.directives.LoadGoogleFontDirective
- All Implemented Interfaces:
Nice2TemplateDirective
,TemplateIdentifiers
,freemarker.template.TemplateDirectiveModel
,freemarker.template.TemplateModel
public class LoadGoogleFontDirective
extends Object
implements Nice2TemplateDirective, TemplateIdentifiers
Includes Google Fonts in your CSS.
On some environments, you can simply include the Google fonts CSS like Google advises you to do it:
@import url('https://fonts.googleapis.com/css?family=Roboto:400,700');
However, this doesn't always work properly (i.e. generating correspondence footers in the OpenShift environment).
In this case, you can use this directive to fetch the contents of the CSS and include it in your stylesheet.
Parameters:
* url: The URL of the Google Fonts CSS file.
Usage example:
[@loadGoogleFont url="https://fonts.googleapis.com/css?family=Roboto:400,700"/]
→ includes the content of that CSS file:
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxP.ttf) format('truetype'); } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 700; src: local('Roboto Bold'), local('Roboto-Bold'), url(https://fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmWUlfBBc9.ttf) format('truetype'); }
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.templating.api.freemarker.directives.TemplateIdentifiers
TemplateIdentifiers.Scope
-
Field Summary
Fields inherited from interface ch.tocco.nice2.templating.api.freemarker.directives.TemplateIdentifiers
BASEDATA_VAR, DELIMITER_PARAM, ENTITY_PARAM, INLINE_TEMPLATE, KEY, LIMIT_PARAM, LINE_END_PARAM, LINE_START_PARAM, NAME_PARAM, PATH_PARAM, PATHS_PARAM, PATTERN_PARAM, RECIPIENT_VAR, SCOPE_PARAM, SENDER_VAR, SINGLE_BASE_VAR, TARGET_VAR, VALUE_PARAM
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
LoadGoogleFontDirective
public LoadGoogleFontDirective()
-
-
Method Details
-
execute
public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException, IOException - Specified by:
execute
in interfacefreemarker.template.TemplateDirectiveModel
- Throws:
freemarker.template.TemplateException
IOException
-