+
Skip to content

Feature request: detect non-empty lists #39

@daattali

Description

@daattali

If I have the following data:

data <- list(users = list(list(name = "bob"), list(name = "alice")))

I might want to know if the list is empty or not. For example, this would be my desired template:

template <- "{{#users.length}}Users: {{#users}}{{name}} {{/users}}{{/users.length}}{{^users.length}}No users{{/users.length}}"

It uses .length as a conditional that is true if there are any elements and false if it's empty.

This is not an official standard mustache feature, but it is implemented in some languages. See here for details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载