Class TokenDirectiveModel

java.lang.Object
org.apache.juneau.console.freemarker.TokenDirectiveModel
All Implemented Interfaces:
freemarker.template.TemplateDirectiveModel, freemarker.template.TemplateModel

public final class TokenDirectiveModel extends Object implements freemarker.template.TemplateDirectiveModel
The <@token name="--jc-…" value="…"/> / <@token name="--jc-…" alias="var(--jc-…)"/> chrome FreeMarker directive: one custom theme-token override authored inside a <@theme> element.

Exactly one of value= / alias= is required, and they are mutually exclusive — they are the two disjoint Theme channels:

  • value= is a leaf: a CSS literal, or a var(--jc-name) reference that Theme.Builder#token(String, String) resolves to a literal at build time (the substring var( does not reach the served leaf map).
  • alias= is a derived reference: a var(--jc-name) that Theme.Builder#alias(String, String) keeps as a reference surviving to the wire. A literal cannot express a live alias — that is why the attr exists.

The name/value/target guards and reserved-namespace rejection are the Java Theme.Builder's own (fail closed); an IllegalArgumentException it raises is re-surfaced through FtlAttrLists.reject(String) so its exact sentence reaches the HTTP 500 body. The directive writes no markup — it folds the declaration into the enclosing ThemeBuildContext, which <@theme> builds after its body pass.

scheme="dark" declares the token for the dark colour scheme only. Dark declarations render in their own html:root[data-jc-scheme="dark"] rule after the light override block, holding only the declared names. A dark value= must be a literal (a var() leaf would resolve against the light palette); a dark alias= stays a live reference. dark is the only accepted value: a light token omits scheme=.

Example:

<@theme name="light-red"> <#-- A leaf: a literal. --> <@token name="--jc-pill-red-bg" value="#fdeceb"/> <#-- An alias: a live reference. --> <@token name="--jc-tab-bar-bg" alias="var(--jc-card-bg)"/> <#-- Dark scheme only. --> <@token name="--jc-link" value="#6cb4ff" scheme="dark"/> </@theme> <#-- Rejected: both value= and alias=, neither one, or a reserved --jc-chrome-* name. --> <@token name="--jc-x" value="#fff" alias="var(--jc-accent)"/> <@token name="--jc-x"/> <@token name="--jc-chrome-control-height" value="26px"/>

Since:
10.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The shared-variable name this directive registers under.

    Fields inherited from interface freemarker.template.TemplateModel

    NOTHING
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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