From c171d702afe8710bfd9ed7aff5041c23aaa53ec4 Mon Sep 17 00:00:00 2001 From: Chris Nienhuis Date: Fri, 16 Nov 2012 13:49:49 -0600 Subject: [PATCH] Issue #364 - IE9 whitespace bug fix In IE9, if you have whitespace and/or carriage returns between table elements, it causes IE9 to render a blank column and pushes all the content one column to the right. It seems the best solution is to strip it out of the template string when you compile a template. If you search google for "IE9 renders blank cells" you'll find lots of references to this problem. --- lib/handlebars/compiler/compiler.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index 7578dd2d7..28b9b2b00 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -1045,7 +1045,10 @@ Handlebars.precompile = function(string, options) { Handlebars.compile = function(string, options) { options = options || {}; - var compiled; + var compiled, + re = /(\)\s+|\s+(\<\/t.{1-4}\>)|\\r|\\n/gim, + string = string.replace(re, '$1'); + function compile() { var ast = Handlebars.parse(string); var environment = new Handlebars.Compiler().compile(ast, options);