Skip to main content Link Search Menu Expand Document Toggle dark mode Copy Code (external link)
paperwork.help

this and . : The Current Item

Inside a loop or with block, this - or a leading . - refers to the current item.


On this page

Syntax

{{this}}
{{this.property}}
{{.property}}
{{.}}

Examples

Data:

builder.WithData("model", new {
    tags = new[] { "urgent", "finance" },
    items = new[] {
        new { name = "Widget", price = 10.0 },
        new { name = "Gadget", price = 15.5 }
    }
});

Template:

{{#each model.tags}}
    <span>{{this}}</span>
{{/each}}

{{#each model.items}}
    <p>{{this.name}} - {{.price}}</p>
{{/each}}

Output:

urgent finance
Widget - 10
Gadget - 15.5

Notes

  • this.name and .name are the same.
  • A plain name is also looked up on the current item, so inside a loop {{name}} usually works too. this makes it clear, and avoids a clash with a data name of the same name.
  • Outside any loop or with block, this is the document’s data.

See Also