-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing an object into data property causes an error. #28
Comments
Hi @gearboxdesign, which version of |
also, is that |
Hi guys thanks for the responses, I am currently using 0.4.0, it is in the grunt config, ok so a more complete example, do let me know if I'm going about this a ridiculous way! So I need to generate a series of index pages which contain links to each files / directories which sit underneath them in a site structure, essentially exactly what a standard server generated index would do. So I have already written something which, once the initial assemble process has ran to create the static site, scans the output directly creating a tree of paths, so now I recursively run through the tree creating a assemble subtask on the fly in which I want to pass a very specific data object, i.e. the current tree object which pertains to that index... i.e. 'use strict';
var getDirs = require('./getDirs.js'),
path = require('path'),
_ = require('lodash');
module.exports = function(grunt) {
grunt.registerMultiTask('indexer', '.', function() {
var options = this.options({
baseDir: null,
assembleOptions: null
});
if(!this.files.length) {
grunt.log.warn('No files found.');
}
this.files.map(function (file) {
return getDirs(file.src, options);
}).forEach(_.partial(writeFiles, options));
});
function writeFiles (options, content) {
if (content.paths) {
grunt.config.set('assemble.indexer-' + content.id, {
options: _.extend({
data: content
}, options.assembleOptions),
src: options.template,
dest: path.join(options.baseDir, content.url, 'index.html')
});
grunt.task.run('assemble:indexer-' + content.id);
content.paths.forEach(_.partial(writeFiles, options));
}
}
}; I do wonder a little if all this is necessary, but I was unable to achieve what I wanted with the pages option i.e. gathering a nested structure without extraneous use of helpers, for the above you can assume content.id is a unique id for the task. the content argument is an object, but even if I try something simple in its place such as an empty object literal or one with test properties such as foo:'bar' I get the same error. For reference the original default assemble config options are: options: {
deploy: grunt.option('deploy'),
layoutdir: '<%= project.dirs.views.layouts %>',
partials: [
'<%= project.dirs.views.elements %>/**/*.hbs',
'<%= project.dirs.views.components %>/**/*.hbs'
]),
helpers: ['handlebars-helpers'],
data: '<%= project.dirs.views.data %>/**/*.json'
} Thanks... |
Digging a little deeper it would seem that lib/assemble.js line 43 forces any data passed into an array which by the time it reaches tasks/assemble.js line 55 it is assumed the contents are file globs and passing the object through file.expand seems to cause the error... am I trying to do something it simply can't do here? |
I ran into the same problem.
See https://github.com/assemble/grunt-assemble/blob/master/CHANGELOG#L28 That's weird. Version 0.4.0 contains changelog for version 0.4.41? how can I get version 0.4.41? |
Oh, so 0.4.41 refers to a release of the original assemble library, right? I'm confused 😕 |
The changelog is wrong. this library is |
Thanks for clearing that up |
no prob sorry for the confusion |
create tests
Hi all,
According to the docs you are able to pass in an object directly into the data attribute, each time I try I seem to get the error:
Warning: undefined is not a function...
Snippet:
Whilst usually I would just pass in a data file in, I have a very specific case in which I need to pass in an object on this occasion.
Any help would be much appreciated...
The text was updated successfully, but these errors were encountered: