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

Ghost 0.4 Broke Template #47

Closed
jfreak53 opened this issue Jan 13, 2014 · 80 comments
Closed

Ghost 0.4 Broke Template #47

jfreak53 opened this issue Jan 13, 2014 · 80 comments

Comments

@jfreak53
Copy link

I just upgraded to Ghost 0.4 and it seems to break the template. On the main page I get this 500 error:

You must pass a string or Handlebars AST to Handlebars.compile. You passed function (context, options) { if (!compiled) { compiled = compileInput(); } return compiled.call(this, context, options); }

Post pages and Static pages work perfectly fine if I manually type in the url. But the main page seems to be broken when using this template. I know it's the template as when I change to the default theme it works.

@subho007
Copy link
Contributor

Not only does it shows 500 error, but also in the frontpage the post descriptions are 2-3 words only. Have a look at the mess in http://www.subho.me/

@jfreak53
Copy link
Author

@subho007 At least you got it to work, mine doesn't even work. How did you get your's to work, what did you change?

@subho007
Copy link
Contributor

ahhh, made it working atlast,

Here's what I did @jfreak53

  1. went to ghost/content/themes/ghostium/partials/custom and chmod everything to 755 chmod 755 *
  2. making the description longer, changed it ghost/content/themes/ghostium/partials/post/list.hbs find {{excerpt characters= and change the value

@jfreak53
Copy link
Author

Ok, that chmod fixed it for a short time. But every time I create a new post it breaks again. I have to stop Ghost and Restart it every time I delete or create a new post.

@jfreak53
Copy link
Author

Or even edit a post :(

@subho007
Copy link
Contributor

@jfreak53 it works perfectly on my side, can you paste the error message which comes?
I also recommend you to go to the ghost/ root folder and do a chmod -R 755 . which might fix the solution.

@jfreak53
Copy link
Author

That seems strange that everything has to be 755, that's really bad permissions on a linux machine for web files. The error message is still the one I posted above, the 500 error.

@subho007
Copy link
Contributor

@jfreak53 755 permission is not bad, 777 permission is bad. 755 gives the groups and everyone the right to read and execute the file. They cannot write to the file. 777 would permit writing to the file by the group and everyone

@jfreak53
Copy link
Author

Nope, still same problem after 755 everything:

You must pass a string or Handlebars AST to Handlebars.compile. You passed function (context, options) { if (!compiled) { compiled = compileInput(); } return compiled.call(this, context, options); }

I don't understand how the default template works fine without doing the 755 but this template does not. Seems to be something in the template not directory permissions. That being said, 755 didn't fix it.

@subho007
Copy link
Contributor

@jfreak53 also can you clarify, when do you see the error? do you see the error when inside http://yoursite.com/ghost/editor or from the frontpage ?

@jfreak53
Copy link
Author

Frontpage only.

@p0rkjello
Copy link

I am seeing the same issue. Can you explain the change you made to list.hbs?

ERROR: You must pass a string or Handlebars AST to Handlebars.compile. You passed function (context, options) {
    if (!compiled) {
      compiled = compileInput();
    }
    return compiled.call(this, context, options);
  }
ErrorPage
Ghost caught a processing error in the middleware layer.

Error: You must pass a string or Handlebars AST to Handlebars.compile. You passed function (context, options) {
    if (!compiled) {
      compiled = compileInput();
    }
    return compiled.call(this, context, options);
  }
    at new Error (<anonymous>)
    at Error.Exception (/var/ghost/node_modules/express-hbs/node_modules/handlebars/dist/cjs/handlebars/exception.js:6:41)
    at compile (/var/ghost/node_modules/express-hbs/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:444:11)
    at HandlebarsEnvironment.hb.compile (/var/ghost/node_modules/express-hbs/node_modules/handlebars/dist/cjs/handlebars.js:18:12)
    at Object.invokePartialWrapper [as invokePartial] (/var/ghost/node_modules/express-hbs/node_modules/handlebars/dist/cjs/handlebars/runtime.js:42:28)
    at Object.eval (eval at <anonymous> (/var/ghost/node_modules/express-hbs/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:179:23), <anonymous>:58:17)
    at /var/ghost/node_modules/express-hbs/node_modules/handlebars/dist/cjs/handlebars/runtime.js:92:31
    at /var/ghost/node_modules/express-hbs/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:467:21
    at render (/var/ghost/node_modules/express-hbs/lib/hbs.js:268:15)
    at compileFile (/var/ghost/node_modules/express-hbs/lib/hbs.js:302:14)

@oswaldoacauan
Copy link
Owner

Im testing it right now and everything is working just fine. :/

Have you guys changed something in Ghostium/Ghost?

I tested on Windows 7 with Node v0.10 with a clean version of Ghost/Ghostium and works perfectly.

@subho007
Copy link
Contributor

Ahhh I found the problem now, this is due to the issue at TryGhost/express-hbs#23 (even though the issue is fixed, but I still doubt it) Any themes with partial is facing this problem in a freshly installed Ghost with npm install --production

The fix is simple, do an npm install (Note: this will install whole lot of extra files) instead of npm install --production

@robraux
Copy link

robraux commented Jan 13, 2014

@oswaldoacauan the first time it's loaded, it appears correctly. I reload the page and receive the same error message detailed in this thread. My install is clean, same as you, 0.10.24, but on linux.

@subho007 your proposed fix did not resolve the problem for me. I saw no difference. And yes, I restarted ghost after npm install.

@oswaldoacauan
Copy link
Owner

@robraux Im at work right now, will take a look at this later at home

@jfreak53
Copy link
Author

Same thing, I did npm install and restarted but still same problem. Thanks @oswaldoacauan

@jfreak53
Copy link
Author

FYI, for me this is upgraded from Ghost 0.3 not a clean install as I already have a blog running on 0.3 and needed to upgrade. For upgrade I followed Ghosts instructions on their site.

@ghost
Copy link

ghost commented Jan 13, 2014

Same problem here. First visit: all fine. Second: 500 error

"You must pass a string or Handlebars AST to Handlebars.compile. You passed function (context, options) { if (!compiled) { compiled = compileInput(); } return compiled.call(this, context, options); }"

Only on front page, backend works.

@dannynelson
Copy link

Same problem, did npm install and chmod -R 755 . in the root folder. Thank you for your help!

@bkbooth
Copy link
Contributor

bkbooth commented Jan 13, 2014

Yeah, just wanted to chime in to say that I'm having this issue too. Upgrading from ghost 0.3.3 to ghost 0.4. Tried an npm install but I'm not going to chmod -R 755, I know this won't fix the issue in my case. Casper theme works fine, just ghostium and just on the homepage I'm seeing the error message.

@drosboro
Copy link

Also having this issue. In addition, I just did a fresh install of Ghost 0.4, a fresh clone of ghostium, and ran into the same 500 error as when I had upgraded. First visit was fine, second visit threw the error, only on front page.

@Ardakilic
Copy link
Contributor

Also having the issue, for the first minutes it's okay, then it throws the same error at first post.

Also, as mentioned, front page was showing only 2-3 words, unlike it should more.

The admin panel works nice though. I've swithched back to casper for now.

@oswaldoacauan
Copy link
Owner

Can you guys tell me these infos?

  • Ghostium version
  • Node version
  • OS (Operating system)

@jfreak53
Copy link
Author

  1. Most recent as of 5 days ago, cloned from GIT.
  2. 0.10.24
  3. SO??

@Ardakilic
Copy link
Contributor

  1. Ghostium cloned from GIT, 4 days ago
  2. 0.10
  3. SO?

I'm using RedHat Openshift, both updating Ghost from 0.33 to 0.4 and 0.4 clean installation gives me the issue, if that would help.

@oswaldoacauan
Copy link
Owner

Sorry about the "SO" typing error, i mean OS (operating system).

cc @jfreak53 @Ardakilic

@Ardakilic
Copy link
Contributor

@oswaldoacauan Oh Okay then. Both on OpenShift's auto Ghost installer+update, and node.js + manual clean installation, the issue remains for me.

@jfreak53
Copy link
Author

Ohh, on that system I'm running Ubuntu 13.04

@mgutz
Copy link

mgutz commented Jan 16, 2014

@subho007 Actually I was not able to reproduce this bug in express-hbs. I created tests to try and reproduce and could not. Also the code above bypasses express-hbs and sets properties on the internal handlebars.partials[] collection. The preferred method, which express-hbs uses, is handlebars.registerPartial. I can't reproduce the issue so it's hard for me to assist.

@subho007
Copy link
Contributor

@mgutz this is the fault of Ghost, you can have a look at https://github.com/TryGhost/Ghost/blob/master/core/server/helpers/template.js which is responsible for this error. recreating it from the above code should be able to reproduce the issue. The fault is at hbs.handlebars.compile(partial);
Thanks to @bondarewicz for pointing it out in the start.

@voigt
Copy link

voigt commented Jan 16, 2014

@subho007 okay, what you said makes sense. unfortunately it had no effect at all :/
The first visit everything is well, after refresh -> 500.

Of course I did all the necessary reloads and restarts...

@subho007
Copy link
Contributor

@voigt check once more if you have made the changes in content/themes/ghostium/partials/custom/featured.hbs and not in content/themes/ghostium/src/partials/custom/featured.hbs you donot need to touch src folder inside ghostium

@voigt
Copy link

voigt commented Jan 16, 2014

@subho007
Okay, I did a complete new installation:

  1. A new copy of Ghost 4.0.0
  2. editing config.js
  3. extract the ghostium-master.zip to /content/themes/ghostium
  4. edited content/themes/ghostium/partials/custom/featured.hbs and pasted {{! This is featured comment }} into the file
  5. chmod -R 755 . in root
  6. npm install --production in root
  7. npm start --production

The problem persists. First load: everything works. Reload: Error 500. Backend and blogposts do work...

node version v0.10.18
npm version `

edit
Okay, after all this i did another npm install (without --production). Then reboot. Result: npm start gives me a working ghost instance. The npm start --production instance has still the problem.

@mgutz
Copy link

mgutz commented Jan 16, 2014

@voigt Please try npm install express-hbs@0.7.0-pre in the ghost directory. Ghost is using an old version of express-hbs.

@mgutz
Copy link

mgutz commented Jan 16, 2014

Also the correct commands for chmod should be:

find . -type d | xargs chmod 0755
find . -type f | xargs chmod 0644

You don't want to make all your files executable

@voigt
Copy link

voigt commented Jan 16, 2014

Still no progress with production mode. Even after deleting the old express-hbs...
What does the production mode different then the devmode? There is absolutely no problem in devmode!

Just an idea: temporary featured.hbs is not needed. So why not preventing it from beeing loaded? Where is it declared as to be loaded?

Another idea: is featured.hbs really the only empty file?

@bitIO
Copy link

bitIO commented Jan 17, 2014

@mgutz just installed express-hbs@0.7.0-pre and that solved the problem.

@ghost
Copy link

ghost commented Jan 20, 2014

I'm running in the official ghost hosted platform (Version: 0.4.0-moya1), I implemented the comment fix in featured.hbs (yes it's definitely not the one in /src/). The only time I get the 500 error is after I go into the admin section and edit/ create a post. I can fix it by re-uploading the zip of Ghostium through Ghost.org. Thought you'd be interested as I saw nobody above using the hosted platform with this issue

@bondarewicz
Copy link

@MikeyJck same here however changing a src/ file fixed an issue?

@mgutz
Copy link

mgutz commented Jan 21, 2014

@bondarewicz, @MikeyJck Please try npm install express-hbs@0.7.3-pre, found another case which causes the error above and it's a problem with Handlebars. I added workaround.

@voigt
Copy link

voigt commented Jan 21, 2014

express-hbs@0.7.3-pre finally fixed the problem for me now. Thank you for your efforts!

@bondarewicz
Copy link

@mgutz "running in the official ghost hosted platform"

@mgutz
Copy link

mgutz commented Jan 21, 2014

@bondarewicz have no idea what that means, never installed ghost until this issue was linked from express-hbs issues

@bondarewicz
Copy link

Sorry I've been lazy with explanation... I meant that @MikeyJck and myself are using ghost hosted version on their platform. As far as I'm aware you cannot install/upgrade anything yourself.

@carroarmato0
Copy link

npm install express-hbs@0.7.3-pre and restarting worked for me. Thanks!

@ddonovan
Copy link

Just to add to the numbers, I'm also using ghost.org to host and have tried numerous times to modify and upload the .zip file but each time I get the 500 error after I add/edit a post.

@seanichol
Copy link

I installed express-hbs@0.7.5-pre and 500 error is gone.

However, I still have an excerpt that is being cut at 12 characters. I have updated list.hbs with no change in excerpt.

Ghost = self hosted.

@carroarmato0
Copy link

@ddonovan I have no idea how Ghost hosting works but in my case I had to restart Node, I don't expect them to let you do that manually (maybe ask nicely)

@ddonovan
Copy link

@carroarmato0 For the time being I just removed the line to include featured.hbs from index.hbs. Things seems to work good now.

{{> custom/featured this}}

@ghost
Copy link

ghost commented Jan 28, 2014

@ddonovan where did you make this edit?

@ddonovan
Copy link

Mikey, I made the change inside index.hbs -

<section class="wrapper">
  <div class="wrapper-container">
    {{> custom/featured this}}   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  comment out or remove this line. 

    <section class="post-list">
      {{#foreach posts}}
        {{> post/list this}}
      {{/foreach}}
    </section>

    {{#if pagination}}
      {{pagination}}
    {{/if}}

    {{> footer this}}
  </div>
</section>

@ghost
Copy link

ghost commented Jan 28, 2014

@ddonovan thanks dude, I'll try that and get back to you

@ErisDS
Copy link
Collaborator

ErisDS commented Feb 1, 2014

Ghost 0.4.1 is out and resolves this issue, so this can probably be closed now.

@oswaldoacauan
Copy link
Owner

@ErisDS 👍 thanks Hannah

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