From fb6b5a8320d8e4374e417d57d98d3fd836394272 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Wed, 4 Nov 2015 13:31:15 -0800 Subject: [PATCH] {{{foo}}} when foo is a plain JS object should return JSON --- lib/template.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/template.js b/lib/template.js index 14f396d..933276d 100644 --- a/lib/template.js +++ b/lib/template.js @@ -319,6 +319,8 @@ var Hogan = {}; hChars = /[&<>\"\']/; function coerceToString(val) { + if (typeof (val) === 'object' && val !== null && val.toString === Object.prototype.toString) + return (JSON.stringify(val)); return String((val === null || val === undefined) ? '' : val); }