-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Empty partials cause error 500 #1964
Comments
I was able to reproduce this problem and the fix seems to be to upgrade to latest express-hbs which can be tried by
in the Ghost directory. I fixed a long standing production cache issue. Let me know if that fixes it and I can make a 0.7.0 release. |
@bondarewicz When raising issues here on GitHub, please take a few minutes to read the contributing guidelines. They provide tips on the kind of information to put into an issue. Raising issues with just one or two lines leaves a lot of work for the people reading this to go and find out what you're talking about. @mgutz Thanks for coming and updating us about 0.7.0-pre. Is anyone able to give this a thorough test? |
@bondarewicz Much appreciate the updated issue 👍 I can see 2 different issues here, both related to empty partials.. With the Ghostium theme, Ghost throws a 500 error page: With the Rolls Royce theme Ghost just throws an ugly error message in the console, and never renders the frontend, which is really strange. So firstly, we need to fix it so that no matter what happens, Ghost renders it's 500 error page, and then we should introduce @mgutz's express-hbs fix to resolve the underlying issue with partials in production mode. |
I'm looking into this issue, but looks like an error message occurs in testing environment too. See image: cc: @ErisDS |
@mgutz - I did a thorough test with RollsRoyce theme, node v0.10.24, [email protected], and no success. The issue still occurs. Can you point me to the fix in the express-hbs repo? |
The tests for the original issue was an empty partial: https://github.com/barc/express-hbs/blob/master/test/issues.js#L10-L36 Your error seems different. How can I reproduce? Is it as simple as downloading the RollsRoyce theme and running in --production mode? |
@mgutz @roycehaynes The rollsroyce theme is behaving VERY strangely. In this case the partials are not empty, they contain a comment, and no newline afterwards. The error also is not caught properly. In order to fix the theme for people on the hosted service I'm having to add newlines after the comments in the 3 partials that only contain comments (github_handle.hbs, gravatar_url.hbs and twitter_handle.hbs). I've no idea why this fixes it, but it does. This does seem to be a different problem. It occurs in development mode as well as production mode. The problem that @roycehaynes is reporting here is yet another problem where partials are not found. I'm not sure why that would be happening. I ran into this whilst debugging, but wasn't sure what caused it. After changing permissions and switching themes a few times it seemed to work ok again. |
From the code above ghost is loading partials independently of express-hbs. This seems like a timing problem where the partial has not been cached before the template is rendered. I'll look tonight. |
There's definitely a bug in Handlebars when handling comment only partials As users have said, the fix is to add a space or a newline after the comment. I put a workaround in [email protected] |
@mgutz - What do you mean when you say the partials are loading independently of express-hbs? As far as the RollsRoyce theme goes, I updated and removed all references to partials. Now the partials are explicitly in the default.hbs file. More thoughts on this in another message, but there needs to be a way to provide custom variables within a template that can be set via a config file. I'll look to see if a issue exists for this type of behavior/implementation. |
@roycehaynes The code above in the first message is settting partials directly on the Normal express apps use app.locals for global locals. Maybe ghost can provide a theme init hook for your needs. |
@mgutz I tested pre-2 along with changing the code in Ghost to use |
working on the other issues, hope to release later today |
I have tested with 0.7.5 of express-hbs and am not seeing these errors anymore. |
Since 0.4 there is an exception thrown on main index page:
Occurs when one of below custom/partials is blank:
https://github.com/oswaldoacauan/ghostium/tree/master/src/partials/custom
Exception is thrown here:
Ghost/core/server/helpers/template.js
Line 19 in 968176c
Adding below to an empty partial fixes an issue:
Original issue reported here
The text was updated successfully, but these errors were encountered: