1

I'm trying to template all of the files in a directory and put the result in bin/admin directory such that the destination file has the same name as the source file. However, it seems like the dest in data is the name of file and cannot be specified as a destination directory.

module.exports = function(grunt) {
  grunt.initConfig({
    'template': {
      'process-html-template': {
        'options': {
          'data': {
            'api_url': 'My blog post'
          }
        },
        'files': {
          'bin/admin/': ['src/admin/*'] // <-- Here
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-template');
  grunt.registerTask('default', ['template']);
}

What can I do to template all of the files in src/ and put them in a destination folder with the same name as the source? I tried to use bin/admin/* as the destination, but that just create a file with the filename * in bin/admin. I want to avoid listing all of the files in the source directory manually.

1 Answer 1

2

I figured it out. It's an object with a src and dest attribute.

module.exports = function(grunt) {
  grunt.initConfig({
    'template': {
      'process-html-template': {
        'options': {
          'data': {
            'api_url': 'My blog post'
          }
        },
        'files': [
          {
            expand:true,
            src: 'src/admin/*',
            dest: 'bin/admin/'
          }
        ]
      }
    }
  });

  grunt.loadNpmTasks('grunt-template');
  grunt.registerTask('default', ['template']);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.