gruntjs/grunt-contrib-handlebars

not picking up subdirectories

Closed this issue · 4 comments

I'm trying to use grunt-contrib-handlebars to compile nested paths and it is not picking the templates in subdirectories ./js/templates/foo/bar.tpl is being ignored.

handlebars: {
    compile: {
        options: {
            namespace: false
        },
        files: {
            "<%= tplOutFileMain %>" : ["js/templates/**/*.tpl"]
        }
    }
},

https://stackoverflow.com/questions/20982774/grunt-contrib-handlebars-not-compiling-nested-paths

why did you close?

Ah, sorry if the issue wasn't resolved. I thought maybe it had been figured out after a quick look at the comments of your SO question. Either way, this isn't a handlebars-specific problem. The issue seems to be that your gruntfile isn't configured properly. The files array format supports src-dest pairs, but not that simpler syntax. Check out the configuring tasks guide here.

i'm not sure what i'm doing wrong. everywhere else i can use this syntax and it works.

Disregard my last comment. That is a valid format. The issue must be with your directory structure; this library has nothing to do with pulling together those files. That stuff comes from the grunt core.

I was able to pull in my source files in deeply nested directories via:

    main: {
        files: {
          "build/built": [ './src/**/*.hbs' ]
        }
      }

Maybe try a simpler configuration like this first, then add in the template?