seniorpreacher
seniorpreacher

Reputation: 666

Grunt config - dynamic mapping

I have the following in my Gruntfile.coffee:

    jade:
        options:
            data:
                debug: false
        firstLevel:
            files: [
                expand: true
                flatten: true
                cwd: '<%= srcDir %>/documents/'
                src: ["*.jade"]
                dest: "<%= outDir %>"
                ext: ".html"
            ]
        subLevel:
            files: [
                expand: true
                flatten: true
                cwd: '<%= srcDir %>/documents'
                src: ["/<%= subFolder %>/*.jade"]
                dest: "<%= outDir %>/<%= subFolder %>"
                ext: ".html"
            ]

The firstLevel part is compiling properly, but the subLevel is not matching anything. I have a file structure like this:

project
  -src
    -posts
    -pages
    ...
    index.jade
  -our

I would like to render every sub folder in the src folder. I read here that I could use placeholders in Underscore's style, and then I don't have to specify every folder statically.

What is wrong with my code, how could I fix this to work with sub folders?

Upvotes: 1

Views: 476

Answers (1)

Dancrumb
Dancrumb

Reputation: 27539

If you're just trying to copy everything from

src/XXX/XXX.jade

to

out/XXX/XXX.html

then use

files: [
           {
              expand: true,
              cwd: "<%= srcDir %>/",
              src: "**/*.jade",
              dest: "<%= outDir %>/",
              ext: ".html"
           }
        ]

Upvotes: 2

Related Questions