Syntax for using Hogan/Mustache partials?

605 views
Skip to first unread message

Justin Sheehy

unread,
Jun 10, 2012, 2:23:58 AM6/10/12
to doc...@googlegroups.com

I've recently been playing around a lot in Docpad and seriously considering moving several of my projects over to it.
However, while I've been able to get partials in Eco working according to the examples, I have been unable to tweak the syntax around to get partials to work with Hogan.

I'd rather use Hogan than Eco, and would rather not run all of my layouts through both if I didn't have to.
Like I said, still pretty new to Docpad, and I know Hogan/Mustache handle partials a bit differently than others, so maybe I'm just missing something...

Could anyone tell me the proper setup/syntax I should be using, supposing Docpad can even actually utilize Hogan partials at the moment?
Thanks!

Benjamin Lupton

unread,
Jun 10, 2012, 6:51:39 AM6/10/12
to doc...@googlegroups.com
Happy to help :)

Can you elaborate on what specifically is going wrong? and/or post a code example? That'll really help, as otherwise I'm just shooting in the dark.
Message has been deleted

Justin Sheehy

unread,
Jun 23, 2012, 1:00:22 AM6/23/12
to doc...@googlegroups.com
Hmmm, maybe I'm just asking the wrong question.
Is Docpad's Partials Plugin only meant for being used with Eco?
Or is it supposed to allow partials of any other supported template language (like Hogan/Mustache/Handlebars) to be placed in src/partials and be loaded into a layout file?

-- Justin

Narciso Jaramillo

unread,
Jun 24, 2012, 2:38:46 AM6/24/12
to doc...@googlegroups.com
I had issues with using Jade for partials as well--they're getting included unrendered. Still trying to track down the problem.

nj

Benjamin Lupton

unread,
Jun 24, 2012, 6:16:41 AM6/24/12
to doc...@googlegroups.com
Can someone post a repo that I can fiddle with?

Justin Sheehy

unread,
Jul 1, 2012, 2:11:38 AM7/1/12
to doc...@googlegroups.com
Sure, here's my sandbox for these types of things.
https://github.com/systemexitzero/docpad-sandbox 
I cleared it out mostly so all it has is 2 or 3 files I was using to test out the handlebars/hogan/mustache partials.

Benjamin Lupton

unread,
Jul 10, 2012, 7:39:21 PM7/10/12
to doc...@googlegroups.com
Cool thanks.

Looks like this is the same issue as this one: https://github.com/bevry/docpad/issues/257

Still looking for a fix.

Justin Sheehy

unread,
Jul 17, 2012, 12:31:46 PM7/17/12
to doc...@googlegroups.com
Ah, indeed. 
I originally posted to this group because I thought it to be a problem on my end, not a bug with Docpad.
In that case, would you prefer the conversation is continued on the issue rather than here?

Benjamin Lupton

unread,
Jul 18, 2012, 8:06:14 AM7/18/12
to doc...@googlegroups.com
It's one of those gray areas. We should support this, however it is a question of can we. I'll look into this tomorrow and see what I can come up with. For the meantime you can use the workaround mentioned on that issue here: https://github.com/bevry/docpad/issues/257#issuecomment-6830362

Pete Schirmer

unread,
Nov 6, 2012, 8:30:40 PM11/6/12
to
I was able to get this working with a handlebars helper function: (in docpad.coffee file) 

docpadConfig = {
  plugins:{

   handlebars:{

     helpers:{

       partial:(content, options) -> output = @partial(content, options)
     
}

   }

 }

}

module.exports = docpadConfig


and then using markup like this in the document.html.hb to include the partial: 


{{partial 'my_partial_file.html'}}



Message has been deleted

Benjamin Lupton

unread,
Nov 13, 2012, 8:11:34 PM11/13/12
to doc...@googlegroups.com
Awesome work Pete. There is a pull request here which seems to have taken a different approach: https://github.com/docpad/docpad-plugin-handlebars/pull/1

Mind commenting on it before I merge it in? Cheers!

Pete Schirmer

unread,
Dec 4, 2012, 6:28:29 PM12/4/12
to doc...@googlegroups.com
It seems that does partials by including content defined in the docpad config (coffee/ whatever) which works fine. 
my version just exposes the partial plugin engine to the hb rendering engine.. so you can define the file partials externally. 
Reply all
Reply to author
Forward
0 new messages