concordusapps / grunt-haml

Process HAML templates to precompiled JavaScript or rendered HTML.
https://npmjs.org/package/grunt-haml
MIT License
41 stars 28 forks source link

Is it possible to recursively build the haml files #28

Closed axelson closed 10 years ago

axelson commented 10 years ago

Is there a way to recursively list the haml files to build rather than directly list every folder that contains *.haml files?

joneshf commented 10 years ago

The file patterns for grunt are glob style, so if it's something you can express with glob, then sure.

You can say something like src/**/*.haml. This will find any haml file below the src directory. Or are you looking for something else?

axelson commented 10 years ago

Okay, by mixing that syntax with the 'two' example I can get what I want.

haml: {
  two: {
    files: grunt.file.expandMapping(['_jekyll/**/*.haml'], 'build/', {
      rename: function(base, path) {
        return base + path.replace(/\.haml$/, '').replace(/_jekyll\//, '');
      }
    }),
    options: { language: 'ruby' }
  }
}

Thanks! Although I wish I didn't have to manually remove the jekyll. Is there a way around that? If I just provide something like ['*/_.haml'] grunt never completes.

axelson commented 10 years ago

Nevermind, found a wiki page that explained it. Can I add this to the REAME and submit it as a PR?

Wiki page: http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

My new config:

  haml_files: {
    expand: true,
    flatten: false,
    cwd: '_jekyll',
    src: ['**/*.haml'],
    dest: 'build/',
    ext: '.html',
    options: { language: 'ruby' }
  }
joneshf commented 10 years ago

Please do.