javascript - Escape variable name with Mustache.js -
i have csv file i'm parsing json , sending mustache.js. problem of variable names not formed, end objects may this:
{ 'num.': '1234', 'pass-through': 'yes' }
so how use variables in mustache template? i've tried couple of different approaches.
<td>{{ num. }}</td> <td>{{ 'num.' }}</td> <td>{{ ['num.'] }}</td>
but none of them work (i'd more surprised if did), , can't find in documentation on how escape variable name.
manual
overview: | interpolation tags used integrate dynamic content template.
the tag's content must non-whitespace character sequence not containing current closing delimiter.
this tag's content names data replace tag. single period (
.
) indicates item sitting atop context stack should used; otherwise, name resolution follows:
- split name on periods; first part name resolve, remaining parts should retained.
- walk context stack top bottom, finding first context a) hash containing name key or b) object responding method given name.
- if context hash, data value associated name.
- if context object, data value returned method given name.
- if name parts retained in step 1, each should resolved against context stack containing result former resolution. if part fails resolution, result should considered falsey, , should interpolate empty string.
data should coerced string (and escaped, if appropriate) before interpolation.
in short : can't have element name 'num.'
.
Comments
Post a Comment