patrickkettner / grunt-compile-handlebars

grunt plugin to compile static html from a handlebars plugin
MIT License
115 stars 29 forks source link

Include partials from subfolders / Bugged partial globbing? #22

Closed johannesjo closed 10 years ago

johannesjo commented 10 years ago

I was wondering if there Is way to include partials from subfolders? I got the following configuration:

        template: 'views/pages/**/*.handlebars',
        templateData: 'views/data/**/*.json',
        output: 'html/pages/**/*.html',
        partials: 'views/partials**/**/*.handlebars',
        globals: [
        ]

What is weird, is that I have to use partials**/ otherwise no partials would be found. EDIT: I solved the partials**-problem. It was just a trailing slash too much. I had /views/partials/ instead of views/partials/

What is also not working is including partials from a subfolder. Lets assume I got the following files:

views/page/page.handlebars
views/partials/partial1.handlebars
views/partials/subfolder/partial2.handlebars

// this works in page.handlebars:
{{> partial1}}

// while none of these does
{{> partial2}}
{{> subfolder/partial2}}
{{> subfolder-partial2}}
{{> subfolderpartial2}}
{{> subfolder_partial2}}
patrickkettner commented 10 years ago

what does your folder tree look like?

johannesjo commented 10 years ago

@patrickkettner

views/pages/
views/data/
views/partials/
html/
other-dev-stuff/
patrickkettner commented 10 years ago

your partials are within views?

johannesjo commented 10 years ago

Yes. Shouldn't they be? I adjusted the paths above, as they're actually slightly different (all inside views and another target folder - I thought this would not matter to much).

patrickkettner commented 10 years ago

Doesn't really matter to me, it would just explain why partials/**/*.handlebars isn't matching - it should be views/partials/**/*.handlebars

johannesjo commented 10 years ago

I left out the views-part in the original post, as I assumed that should not matter to much.

patrickkettner commented 10 years ago

its tangential to the actual issue (I havent' had a moment to dig in yet) - just a seperate thought

patrickkettner commented 10 years ago

So the only thing I can think might be happening is if you had partials under the same name but different paths (eg /partials/foo/test.handlebars and /partials/bar/test.handlebars), test would be clobbered. I just added the registerFullPath option that you can add to register helpers and partials under their path, rather than just the filename.

If that isn't the case, could you give me a bit more info? a zip of an example project showing the project would be phenomenal.

patrickkettner commented 10 years ago

I believe this is fixed in 0.7.6 - could you check it out?

patrickkettner commented 10 years ago

I believe this has been fixed, please let me know if it hasn't.

cheers!