leemunroe / grunt-email-workflow

A Grunt workflow for designing and testing responsive HTML email templates with SCSS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

paths to files method

mtsweir opened this issue · comments

I'm trying to use the <%= paths.src %> method to reference files

e.g src: ['<%= paths.src %>/emails/*.hbs'],

it gives me an error:
Warning: An error occurred while processing a template (Cannot read property 'src' of undefined).

Is there a dev dependency that this requires to run? mine currently looks like this:
"devDependencies": {
"assemble": "^0.4.42",
"grunt": "~0.4.5",
"grunt-assemble": "^0.4.0",
"grunt-cdn": "^0.6.5",
"grunt-contrib-clean": "^0.7.0",
"grunt-inline-css": "^0.1.5",
"grunt-juice-email": "^0.1.4",
"grunt-sass": "^1.1.0"
},

Where are you trying to use src: ['<%= paths.src %>/emails/*.hbs']?

Right here:

  // Assembles your email content with HTML layout
  assemble: {
    options: {
      layoutdir: 'src/layouts',
      partials: ['src/partials/**/*.hbs'],
      flatten: true
    },
    pages: {
      src: ['src/emails/*.hbs'],
      dest: 'dist/'
    }
  },

So basically I have had to change these to just src instead of the <% %> method.

I see, glad you got it working. I'm not sure off hand what it was dependent on.

So just in summary i should use an absolute path instead of e.g <%= paths.src %>?

I'm guessing the use of <%= paths.src %> is dependent on a module you removed, but I could be wrong.

What happens if you revert package.json back?

"assemble": "^0.4.42",
    "cheerio": "^0.19.0",
    "ejs": "^2.3.1",
    "express": "^4.12.3",
    "grunt": "^0.4.5",
    "grunt-assemble": "^0.3.1",
    "grunt-autoprefixer": "^2.2.0",
    "grunt-aws-s3": "^0.13.1",
    "grunt-cdn": "^0.6.5",
    "grunt-cloudfiles": "^0.3.0",
    "grunt-contrib-clean": "^0.6.0",
    "grunt-contrib-imagemin": "^1.0.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-express": "^1.4.1",
    "grunt-juice-email": "^0.1.3",
    "grunt-litmus": "^0.1.8",
    "grunt-mailgun": "^1.0.1",
    "grunt-open": "^0.2.3",
    "grunt-replace": "^0.9.3",
    "grunt-sass": "^1.0.0",
    "imagemin-mozjpeg": "^5.1.0",
    "load-grunt-config": "^0.19.0",
    "load-grunt-tasks": "^3.2.0"

It's specifically ejs, I tried adding ejs on its own but still got an error:

Running "assemble:pages" (assemble) task
Warning: An error occurred while processing a template (Cannot read property 'src' of undefined). Use --force to continue.

So I'm assuming its related to the Gruntfile.js where you have defined the paths in the data object?

I see, yes. How does your Gruntfile.js currently look?

Almost there now! exciting. Added 'load-grunt-config' and used the same method which looks great.

Then added the data paths to the Gruntfile.js and now working :-) Do I need to use the <%= %> method? What exactly was the reason to use it?

Gruntfile.js is currently"

module.exports = function(grunt) {

require('load-grunt-config')(grunt, {

// Pass data to tasks
data: {

  // Re-usable filesystem path variables
  paths: {
    src:        'src',
    src_img:    'src/img',
    dist:       'dist',
    dist_img:   'dist/img',
    preview:    'preview'
  }

}

});
};