-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
When the output of a jQuery template is empty, executing 'mustache' function raises Uncaught Syntax error, unrecognized expression.
Here's a test script to reproduce the error :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="mustache.js"></script>
<script type="text/javascript" src="jQueryMustache.js"></script>
<script type="text/javascript">
$(function() {
var emptyData = {"clients": []}; //-> KO
var testData = {"clients": [
{
"personne": {
"nom": "THOMAS",
"adresseResidence": {
"codePostaln": "12000",
"rue": "7, Avenue du Maréchal Foch",
"villen": "Arpajon-sur-Cère",
"codePostal": "12000",
"ville": "Arpajon-sur-Cère",
"id": 1,
"version": null
},
"dateNaissance": "1975-05-16",
"matricule": "00000000",
"prenom": "Olivier",
"deuxiemePrenom": "Pierre",
"nomMarital": null,
"numeroSecuriteSociale": "176081501409491",
"id": 1,
"version": null
},
"dateContact": 1314605754000,
"rib": "000",
"id": 1
} ]
};
$('#clientsList').html($('#templateClients').mustache(emptyData));
});
</script>
</head>
<body>
<script id="templateClients" type="x-tmpl-mustache">
{{#clients}}
<li>
<a href="${ctx}/clients/{{id}}" class="ui-commandlink">{{#personne}}{{nom}}{{/personne}} {{#personne}}{{prenom}}{{/personne}}</a>
</li>
{{/clients}}
</script>
<ul id="clientsList">
<li>
</li>
</ul>
</body>
</html>
To resolve this issue, change follogin line in jQueryMustache.js :
return $(Mustache.to_html(this.text(), data, partial, stream));
with :
return Mustache.to_html(this.text(), data, partial, stream);
Metadata
Metadata
Assignees
Labels
No labels