1. Handlebars Helpers
  2. Nested

Handlebars Helpers

Nested

Do variable substitution on the enclosed text before processing it.

Overview

This helper does an extra round of variable substitution on the enclosed text before processing it, this allows you to treat some parts of your data as string templates and have them evaluated before being used in the ultimate text output.

Syntax

        "{{#nested}}{{[context that contains a string template]}}{{/nested}}"

      

Examples

Prompt referencing other prompt "parts"

This helper can be used to reference other parts of the prompt that themselves contain variable substitution, by wrapping the variable in the {{#nested}} helper.

Example Data

editor
        {
    "template":{
        "data": {
            "prompts": {
                "system": "You are a helpful assistant.  #Introduction {{#nested}}{{template.data.prompts.guidelines}}{{/nested}}",
                "guidelines": "Your name is {{template.data.settings.assistant_name}}.  1. Be concise. 2. Be accurate. 3. Be helpful.",

            },
            "settings": {
                "assistant_name": "Kelly"
            }
        }
    }
}

      

Substitution

editor
        {
    "template":{
        "data": {
            "prompts": {
                "system": "You are a helpful assistant.  #Introduction Your name is Kelly.  1. Be concise. 2. Be accurate. 3. Be helpful.",
                "guidelines": "Your name is Kelly.  1. Be concise. 2. Be accurate. 3. Be helpful.",

            },
            "settings": {
                "assistant_name": "Kelly"
            }
        }
    }
}