How to refer to the name of the field that contains the dot in the mustache pattern?

How to refer to a field name containing a dot in a mustache pattern? For example, if I have a view like

{
  "foo.bar": "my value"
}

then how can i put my valuein a template? The use {{foo.bar}}does not work because the mustache thinks that the point is part of the path, for example, it must be "foo", which has a "bar".

+5
source share
1 answer

You cannot read the key with .in it from Mustache. The Mustache specification indicates what is .used to separate content names. Mustache provides a means of acceleration, but only for HTML content.

Mustache Specification: interpolation

, Mustache. , , .

JavaScript, Jon:

function rename(obj, oldName, newName) {
    if(!obj.hasOwnProperty(oldName)) {
        return false;
    }

    obj[newName] = obj[oldName];
    delete obj[oldName];
    return true;
}

: ...

+5

All Articles