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

getBlock helpers Not Working Properly #10

Open
SdShadab opened this issue Jan 30, 2015 · 2 comments
Open

getBlock helpers Not Working Properly #10

SdShadab opened this issue Jan 30, 2015 · 2 comments
Labels

Comments

@SdShadab
Copy link

Hello,

I am having a bit of an issue getting the getBlock helpers to work properly. I have modified my docpad.coffee file as instructed in the readme, and the code I used in my layout.html.hbs file looks like this:
{{getBlock 'meta'}} so on and so forth, but when I do docpad run, I end up getting [object object] in my output.

I normally use handlebars in my projects, and would prefer to stick to it. Any help would be sincerely appreciated. Thanks.

@djmarcos88
Copy link

I'm getting exactly the same result, and haven't found a way to fix it. Sadly I had to install eco and use it to render getBlock so now I have to use both handlebars and eco on each layout.

@mikeumus mikeumus added the bug label Jun 26, 2016
@macta
Copy link
Contributor

macta commented Mar 23, 2017

I had this problem too, but its quite easy to fix - as per the documentation at https://github.com/docpad/docpad-plugin-handlebars/ you need to add a mapping function for getBlock in your docpad configuration file. Notice how at the end of that mapping function it has .toHTML() - this is what converts the object array to html (which is the first part of your problem).

Then there is another piece to understand, when using your handlebars expression, if you use {{getblock "meta"}}, it will escape the result (and so the .toHTML above) will result in < etc... As is mentioned in the DocPad tutorial for eco, you need to do a similar non-escaping trick in Handlebars and use triple {'s eg: {{{getBlock "meta"}}}, this will then give the result you are after.

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

No branches or pull requests

4 participants