Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unexpected Doctype #50

Open
yoonwaiyan opened this issue Oct 13, 2016 · 1 comment
Open

Error: Unexpected Doctype #50

yoonwaiyan opened this issue Oct 13, 2016 · 1 comment

Comments

@yoonwaiyan
Copy link

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?

@sean-stanley
Copy link

Blaze can't render the doctype line for some reason.

If you write a helper that renders your doctype as a string you can have the doctype you want.

Quick example:
in js file:

Template.yourTemplate.helpers({
    doctype() {
        return '<!DOCTYPE HTML>'
   }
})
{{{doctype}}}

<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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants