Skip to content

Instantly share code, notes, and snippets.

@AndersDJohnson
Last active June 5, 2019 13:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndersDJohnson/7045251 to your computer and use it in GitHub Desktop.
Save AndersDJohnson/7045251 to your computer and use it in GitHub Desktop.
handlebars : {
options : {
processAST: function(ast) {
var Handlebars = require('handlebars');
ast.statements.forEach(function(statement, i) {
if (statement.type === 'partial') {
var partialFile = grunt.util._.find(grunt.task.current.files, function (file) {
return file.src[0].indexOf(statement.partialName.name) !== -1;
});
if (partialFile) {
var parsed = Handlebars.parse(grunt.file.read(partialFile.src[0]));
ast.statements.splice.apply(ast.statements, [i, 1].concat(parsed.statements));
}
}
});
return ast;
}
// ...
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment