Skip to content

Proposal: Limiting context when using implicit iterators #10

Open
@leth

Description

@leth

Given the following context:

{
    name: 'Hello World',
    list: [
        { data: '123', name: 'one' }
        { data: 'abc' }
    ]
}

The following:

{{#list}}
    {{data}} - {{#name}}{{name}}{{/name}}
{{/list}}

Will output something like:

    123 - one
    abc - Hello World

It might be nice if you could syntactically limit the context to the current iteration

{{#list}}
    {{.data}} - {{#.name}}{{.name}}{{/.name}}
{{/list}}

To get:

    123 - one
    abc - 

The use case I have is printing out html sytlesheet include fragments: the optional title attribute is missing, and it's finding the page title attribute up the context stack.

{{#stylesheets}}
    <link rel="stylesheet" href="{{href}}" type="text/css" {{#title}}title="{{title}}" {{/title}}charset="utf-8">
{{/stylesheets}}
....
<h1>{{title}}</h1>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions