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');
    }
 
  • 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 interface freemarker.template.TemplateDirectiveModel
      Throws:
      freemarker.template.TemplateException
      IOException