Skip to content

Error: Unexpected Doctype #50

@yoonwaiyan

Description

@yoonwaiyan

I'm using SSR to render an html template to string so that I can use it to send email, overriding the forgotPassword template in Accounts, but somehow when I use any doctype it raises an error:

I20161013-18:43:25.727(8)? Exception while invoking method 'forgotPassword' Error: Unexpected Doctype
I20161013-18:43:25.730(8)? <!DOCTYPE HTML>  <html xmlns="http:...
I20161013-18:43:25.731(8)?                ^
I20161013-18:43:25.731(8)?     at [object Object].Scanner.fatal (packages/html-tools/scanner.js:45:1)
I20161013-18:43:25.731(8)?     at HTMLTools.Parse.getContent (packages/html-tools/parse.js:117:1)
I20161013-18:43:25.732(8)?     at Object.HTMLTools.parseFragment (packages/html-tools/parse.js:36:1)
I20161013-18:43:25.732(8)?     at Object.SpacebarsCompiler.parse (packages/spacebars-compiler/compiler.js:4:1)
I20161013-18:43:25.732(8)?     at Object.SpacebarsCompiler.compile (packages/spacebars-compiler/compiler.js:12:1)
I20161013-18:43:25.732(8)?     at Object.SSR.compileTemplate (packages/meteorhacks_ssr/lib/api.js:25:1)
I20161013-18:43:25.732(8)?     at Object.Accounts.emailTemplates.resetPassword.html (imports/startup/server/accounts-config.js:10:6)
I20161013-18:43:25.732(8)?     at AccountsServer.Accounts.sendResetPasswordEmail (packages/accounts-password/password_server.js:571:45)
I20161013-18:43:25.732(8)?     at [object Object].forgotPassword (packages/accounts-password/password_server.js:516:12)
I20161013-18:43:25.733(8)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1711:12)

This is how I use SSR when overriding the template:

import { Accounts } from 'meteor/accounts-base';
import { SSR } from 'meteor/meteorhacks:ssr';
Accounts.emailTemplates.resetPassword.html = function (user, url) {
    SSR.compileTemplate('forgotPassword', Assets.getText('forgotPassword.html'));

    var emailData = {
        url: url
    };

    return SSR.render('forgotPassword', emailData);
};

And this is my sample template:

<!DOCTYPE HTML>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="viewport" content="width=&quot;device-width&quot;"/>
</head>

<body>
  <div class="mui-container">
    <div class="mui-panel">
      <p>Hello,</p>
      <p>
       To reset your password, simply click the link below. 
      </p>
      <p>
        {{url}}
      </p>
    </div>
  </div>
</body>
</html>

It is noted that this template works when the doctype line is removed. Anyone has any idea why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions