blueimp/JavaScript-Templates

Trying to replace a variable with object.

piyushdevani opened this issue · 1 comments

Hi,
When i try to replace a variable in template with object value.
it returns [object Object].

template:
"license": {%=map.license%};

data:
{
"title": "JavaScript Templates",
"license": {
"name": "MIT license",
"url": "http://www.opensource.org/licenses/MIT"
},
"features": [
"lightweight & fast",
"powerful",
"zero dependencies"
]
}

output:
"license" : [object Object].

Any way to get
"license": {
"name": "MIT license",
"url": "http://www.opensource.org/licenses/MIT"
}

The JavaScript Templates code is, as the name implies, simply JavaScript.
{%=map.license%} only outputs [object Object] because that's the string representation for this object.
You could define a toString method for your map.license object which presents the data in your desired format.