patrickkettner / grunt-compile-handlebars

grunt plugin to compile static html from a handlebars plugin
MIT License
115 stars 29 forks source link

globalJsonGlobbedTemplate - templateData path doesn't actually matter #60

Open mikemellor11 opened 8 years ago

mikemellor11 commented 8 years ago

From what i've found setting the path in templateData when using the globalJsonGlobbedTemplate technique doesn't actually change anything, it looks in the same place you've set it to find the handlebars/html files. This behaviour is fine, but it might be helpful to set the templateData to '*.json' in the readme as this is all thats needed for it to work.

patrickkettner commented 8 years ago

could you post a demo of the unexpected behavior? I am not replicating.

ch2ch3 commented 8 years ago

@patrickkettner I'm having the same problem. In my Gruntfile I've set templateData: './templates/data/*.json', but running my task with -v gives the following output:

Reading ./templates/pages/index.hbs...OK
Reading ./templates/pages/index.json...ERROR
OK
Reading ./templates/pages/join-us.hbs...OK
Reading ./templates/pages/join-us.json...ERROR
OK
Reading ./templates/pages/press.hbs...OK
Reading ./templates/pages/press.json...ERROR
OK
Reading ./templates/pages/privacy.hbs...OK
Reading ./templates/pages/privacy.json...ERROR
OK
Reading ./templates/pages/terms-and-conditions.hbs...OK
Reading ./templates/pages/terms-and-conditions.json...ERROR
OK

It's not looking in the directory I've defined but in the directory where it's reading the templates from.

ghost commented 8 years ago

This works for me.

   build: {
        files: [{
            cwd : '_handlebars',
            expand: true,
            src: [ '*.handlebars' ],
            dest: '_dist/',
            ext: '.html'
        }],
        templateData: '*.json',
        helpers: '_handlebars/helpers/*.js'
    }   
mikemellor11 commented 8 years ago

Yeah that will work fine, the point i'm making is that if you set a path for templateData it will get ignored and continue to look where the handlebar/html files are, so either change the readme to reflect that or we can look at changing the implementation.

patrickkettner commented 8 years ago

the implementation should definitely be changed - the readme reflects what should be happening.

mikemellor11 commented 8 years ago

I've added a failing test case that displays the issue, i'll try and take a whack at fixing it later if i get a chance. Feel free to take a look for the time being - https://github.com/mikemellor11/grunt-compile-handlebars.git