1. Hashtag Helpers
  2. With

Hashtag Helpers

With

Inject custom object context into an substitution

The with hashtag helper allows you to inject a custom object context into a substitution. This is useful when you want to define a common object structure, then pass in a different object to be used in the substitution.

NOTE

The with hashtag helper does 2 rounds of substitution, use carefully with {{{{skip}}}}

Uses

Usage

Helper name : with

Argument Description
1 The object to use as context under the with data key
Parameter Description
1 The target substitution object, where you want the with.[key] data to substituted into

eg. ~~#with "~~stub.data.person"#~~template.data.canvas.team_member

Examples

Mapping person data

This example shows mapping stub.data.with_data onto with for purposes of substitution.

Stub Data Context

loading...

Usage Example

editor
        {
  "text": "~~#with "~~stub.data.with_data"#{{with.name}} is {{with.age}} years old"
}

      

Result

loading...
NOTE

This specific example could also be achieved with the with built-in Handlebars helper, but the with hashtag helper allows you to pass in a different object to be used in the substitution.

Mapping person data onto an object

This example shows mapping stub.data.with_data onto with for purposes of substitution.

Stub & Template Data Context

loading...

Usage Example

editor
        {
  "actor_object": "~~#with "~~stub.data.with_data"#~~template.data.structure"
}

      

Result

loading...
NOTE

This specific example could also be achieved with the with built-in Handlebars helper, but the with hashtag helper allows you to pass in a different object to be used in the substitution.


Previous <- Target