simonmcmanus/sizlate — Issue #2: Templates with more than one root tag don't work
Author: andrew
Created: 2011-11-28 17:17:44+00:00
State: open

When using a template like:

Hello world

submit

you get an error like:

500 Error: Heirarchy request error
at Object.appendChild (/Users/andrew/Sites/lnug/node_modules/sizlate/node_modules/jsdom/lib/jsdom/level1/core.js:1411:13)
at Object.setChild (/Users/andrew/Sites/lnug/node_modules/sizlate/node_modules/jsdom/lib/jsdom/browser/htmltodom.js:153:17)
at HtmlToDom.appendHtmlToElement (/Users/andrew/Sites/lnug/node_modules/sizlate/node_modules/jsdom/lib/jsdom/browser/htmltodom.js:76:18)
at Object.innerHTML (/Users/andrew/Sites/lnug/node_modules/sizlate/node_modules/jsdom/lib/jsdom/browser/index.js:334:27)
at Object.doRender (/Users/andrew/Sites/lnug/node_modules/sizlate/sizlate.js:40:16)
at Object.render (/Users/andrew/Sites/lnug/node_modules/sizlate/sizlate.js:101:17)
at Object. (/Users/andrew/Sites/lnug/node_modules/sizlate/sizlate.js:137:18)
at ServerResponse._render (/Users/andrew/Sites/lnug/node_modules/express/lib/view.js:422:21)
at ServerResponse.render (/Users/andrew/Sites/lnug/node_modules/express/lib/view.js:315:17)
at /Users/andrew/Sites/lnug/server.coffee:44:16

My fix for this was to wrap the whole template in an empty div:

Hello world

submit

This isn't the ideal solution, I'd prefer not to have to add extra html to fix it, but it should at least mention the restriction in the docs.