Templates

Evaluate inline Velocity code (PUT)

Changed on

Evaluates Velocity (VTL) code supplied directly in the request body — no .vtl file on disk is required — and returns the result. The code is read from a velocity property of the JSON body (properly escaped), or the body may be the raw VTL itself.

The caller requires the Scripting Developer role.

Response shape is decided by the submitted code:

  • If the code populates $dotJSON (e.g. $dotJSON.put("key", ...)), the response is that JSON object.
  • Otherwise the raw evaluated output is returned, with the content type set by the script (defaults to text/plain).

Velocity errors (syntax/parse errors, method-invocation failures, missing resources) are reported as a 400 with a structured body so an automated caller can locate and fix the offending code instead of receiving partial output. Application-level errors set by the script via $dotJSON.put("errors", ...) are also returned as 400.

Warnings — dotCMS evaluates Velocity in non-strict mode, so an undefined reference ($noSuchVar) renders as literal text and a method returning null produces no output. These likely-typos are collected and, on a successful response, returned in the X-Dot-Velocity-Warnings header (a JSON array); on a 400 they appear in the warnings field of the body.

put/api/vtl/dynamic/{pathParam}

Request

Path parameters

pathParamstring required

Request body

string required

Response

Velocity evaluated successfully; body is the raw output or the JSON object produced by the script

Changes

    • breaking

      added the pattern .* to the path request parameter pathParam

    • info

      api operation id dynamicPut_3 removed and replaced with dynamicPut_2

    • info

      api tag Templates added

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the success response with the status