I'm trying to get prettify to run through one directory and prettify the html files into the same directory after Assemble creates the files. When running the default task together, prettify throws an error:
Running "prettify:indent" (prettify) task
Warning: Object 2 has no method 'indexOf' Use --force to continue
Subsequently, when I run each task individually everything works fine:
$ grunt assemble; grunt prettify
Here is my Gruntfile:
site: grunt.file.readYAML('src/template/data/site.yml'),
assemble: {
options: {
prettify: {indent: 2},
marked: {sanitize: false},
data: "src/template/data/site.yml",
layoutdir: 'src/template/layouts',
},
all: {
options: {production: false,layout: 'default.hbs'},
files: [
{ expand: true, cwd: 'src/template/pages', src: ['**/*.hbs'], dest: 'dist/' }
]
}
},
prettify: {
options: {
indent: 4,
wrap_line_length: 78,
brace_style: 'expand',
},
all: {
expand: true,
cwd: 'dist/',
ext: '.html',
src: ['*.html'],
dest: 'dist/'
}
}
Can someone point me in the right direction? Can prettify output to the same source directory?
Remove prettify: {indent: 2}
from Assemble options.
assemble: {
options: {
marked: {sanitize: false},
data: "src/template/data/site.yml",
layoutdir: 'src/template/layouts',
},
all: {
options: {production: false,layout: 'default.hbs'},
files: [
{ expand: true, cwd: 'src/template/pages', src: ['**/*.hbs'], dest: 'dist/' }
]
}
},
You already specify custom options in prettify
task
prettify: {
options: {
indent: 4,
wrap_line_length: 78,
brace_style: 'expand',
},
// Specify a number to padcomments
all: {
files: [
{expand: true, cwd: 'dist/', src: ['*.html'], dest: 'dist/', ext: '.html'}
]
}
},
Specify prettify: {indent: 2}
in Assemble options mean Grunt will looking for task prettify:indent
with options src: 2
and dest: indent
which is not exist in your Gruntfile.