Using Templater Data in Expressions

In Templater 2.8.0 and later, you can use data in expressions by referencing the Source Text property of a dynamic text layer or any data parameter from Templater's JSON footage layer. Because all Templater data are interpreted as Strings, it is useful to cast them as other data types within your expression code. For example, you might want to cast Templater's String data as Integer, Float, Array, Boolean, or JSON Object for processing by your code.

In expression code, referencing JSON footage is a more user-friendly and intuitive process, but it leverages a feature in After Effects that may require manual interaction during batch processes. As of After Effects 15.1.1, we recommend referencing dynamic text layers' Source Text property in expression code as a more stable solution.

ClosedReferencing dynamic text layers

  1. Map data to a text layer according to instructions in Mapping Templater Data to Layers.
  2. In After Effects, reveal the text layer's Source Text property.
  3. In another layer, use a property's pickwhip to reference the dynamic layer's Source Text property within the expression code.
  4. If necessary, add expression code that casts the referenced Source Text value as a Float, Integer, or Array. If your expression code requires a String, you can reference it without casting.
    For example:
    • Use parseInt() to cast a String as an Integer.
    • Use parseFloat() to cast a String as a Float.
    • Use parseNumber() to cast a String as either an Integer or a Float. This method determines which type is needed.
    • Use eval() to cast a String as an Object or Array.
  5. Finish entering expression code.

ClosedReferencing data parameters from Templater's JSON footage

WARNING  Mapping data to expressions is an experimental feature, and is supported as such until a future release of After Effects. As of After Effects version 15.1.1, a modal dialog requires user interaction when the source of an imported JSON footage item changes structure. This dialog notice can interfere with Templater's batch processes.

  1. In the Templater Preferences dialog, in the Data Source section, enable the Import Templater data as JSON footage preference. When this setting is enabled, Templater automatically creates a JSON file with data from a single job and imports it into the project.
  2. Link your data source to your After Effects project. See Data Source for more information.
  3. In the main Templater panel, in the Output Options section, set the Preview uses dropdown menu to any value other than "current state".
  4. Click Preview.
    A file titled templater-data.json appears in the project panel. For each processed job, Templater overwrites the templater-data.json file with that job's data.

    NOTE  The templater-data.json file will only ever have one object in the file's root JSON array. Also, all property values in the templater-data.json file are always Strings data due to how After Effects handles changes in imported JSON footage items.

  5. Click and drag the templater-data.json file to the target composition's timeline to add it as a layer within the composition. Alternatively, you can add it to a composition nested within your target composition.
  6. If you plan to use Templater's replication feature, apply the Templater Settings effect to the JSON footage layer. Go to Effect Dataclay Templater Settings.
  7. Reveal the JSON layer's Data property group as well as the dataOutline 0 property group to reveal the property keys in the templater-data.json file. These correspond to the column names for spreadsheets or property keys in your JSON feed.
  8. Edit the expression for your chosen layer property. Use the field's pickwhip to reference the specific parameter from the dataOutline 0 group under the templater-data.json file.
  9. If necessary, add expression code that casts the String value as a Float, Integer, or Array. If your expression code requires a String data type, you can directly reference it without casting it.
    For example:
    • Use parseInt() to cast a String as an Integer.
    • Use parseFloat() to cast a String as a Float.
    • Use parseNumber() to cast a String as either an Integer or a Float. This method determines which type is needed.
    • Use eval() to cast a String as a JSON object or an array.
  10. Finish entering the property's expression code.