Question

I'm new to handlebars and Meteor, and I'm trying to implement Skeleton with a new project. However, when I drop the default Skeleton code into a fresh Meteor project I get the following error:

Exception while bundling application:

Error: Couldn't parse .. um .. some HTML file, on some line. sorry

My reading suggests that this has something to do with handlebars not being normal HTML and the Doctype lines not being parsed correctly?

What exactly causes this error, and how do I go about fixing it?

Was it helpful?

Solution

It's helpful to remember that .html files in Meteor are really a file format for defining Handlebars-style templates, not HTML docs in the sense we're used to seeing from a server. There's no need for fully-formed HTML docs in Meteor apps, because each Meteor client builds its own DOM in the browser by running JavaScript sent down from the server.

The only HTML the Meteor server sends to the client is an initial basic document that just references stylesheet and JS bundles with <link rel...>.

So the only three top-level tags allowed in these Handlebars files are:

  • <template> : Defines a Handlebars style template. The HTML inside the template tag compiles to a JS function on the client.

  • <head> : The contents of all the <head> tags in every HTML file in your project are concatenated and delivered to the browser as the initial HEAD section of the document.

  • <body> : Same as above, but defines the inital contents of the <body> tag instead of <head>.

There's no place here for DOCTYPE, for example. (And unfortunately, no place for HTML comments either, but we'll work on that.)

OTHER TIPS

Also, it may be as simple as where you put the code. If you have it going to both the client and the server, you'll commonly get this error with javascript/other code that the server won't (and shouldn't) process.

Make sure you separate your code out so that what's supposed to be on the client only is actually on the client only. If you have multiple html files in the general folder, for example, the server would try to interpret them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top