Class AssetUrlMethodModel

java.lang.Object
org.apache.juneau.console.freemarker.AssetUrlMethodModel
All Implemented Interfaces:
freemarker.template.TemplateMethodModel, freemarker.template.TemplateMethodModelEx, freemarker.template.TemplateModel

public final class AssetUrlMethodModel extends Object implements freemarker.template.TemplateMethodModelEx
The assetUrl(path) FreeMarker method: appends ?v=<crc32> of an adopter's own bundled static asset to its URL path, so a browser cannot keep a stale copy after a deploy.

Registered by ConsoleFreemarkerMixin when the builder is given ConsoleFreemarkerMixin.Builder.adopterAssets(ClassLoader, String). The token is the same CRC32 hash Juneau uses for its own assets, computed once per path and cached. A path that already has a query string, is not context-root-absolute (e.g. an external URL), or names no bundled resource is returned unchanged; the last case also logs a warning once per path when dev mode is on.

Example:

<script src="${assetUrl('/js/app.js')}"></script> <#-- /js/app.js?v=1a2b3c4d -->

Since:
10.0.0
  • Field Details

  • Method Details

    • exec

      public Object exec(List args) throws freemarker.template.TemplateModelException
      Specified by:
      exec in interface freemarker.template.TemplateMethodModel
      Specified by:
      exec in interface freemarker.template.TemplateMethodModelEx
      Throws:
      freemarker.template.TemplateModelException