foundation-emails icon indicating copy to clipboard operation
foundation-emails copied to clipboard

[Foundation for Emails] Data under `src/data` not available as a global variable

Open claudiamatosa opened this issue 9 years ago • 17 comments

Hi all,

First of all, thank you so much for the amazing framework - it made it much easier to scaffold a quick HTML e-mail.

I am using the SASS + Panini version, and ran into a documentation mismatch. Under Custom variables, it says we can drop any .yaml or .json file into src/data and the filename will be made available as a global variable in the handlebars templates. However, I only managed to make it happen by adding data: 'src/data' to the initialising function of Panini, in the generated Gulpfile (line 55). Maybe it was just missing in the generator?

How can we reproduce this bug?

  1. Generate a new project using foundation new --framework ${folderName}.
  2. Follow the instructions under Custom variables to create a custom global variable.
  3. Rebuild.
  4. Verify that the variable is not available.

claudiamatosa avatar Jul 28 '16 12:07 claudiamatosa

Also running into this issue.

seanogdev avatar Sep 12 '16 16:09 seanogdev

This pull request seems to fix it for Panini: https://github.com/zurb/panini/pull/82

So i guess we have to wait a lil bit

jvandenaardweg avatar Sep 13 '16 19:09 jvandenaardweg

Also running into this issue.

mcat avatar Nov 25 '16 20:11 mcat

Still the same here :/

diverent2 avatar Dec 20 '17 19:12 diverent2

Bump.

DanielRuf avatar Mar 11 '18 21:03 DanielRuf

Same issue :(

werschrul avatar Mar 27 '18 10:03 werschrul

I found other discussions that mentioned adding "data: 'src/data'," to the gulp file.

// Compile layouts, pages, and partials into flat HTML files // Then parse using Inky templates function pages() { return gulp.src('src/pages/**/*.html') .pipe(newer('dist')) .pipe(newer('src/partials/**/*.html')) .pipe(panini({ root: 'src/pages', layouts: 'src/layouts', partials: 'src/partials', data: 'src/data', // Added the ability to use data helpers: 'src/helpers' })) .pipe(inky()) .pipe(gulp.dest('dist')); }

bshomer28 avatar Apr 10 '18 15:04 bshomer28

We know about this. The docs are currently not uptodate.

DanielRuf avatar Apr 10 '18 15:04 DanielRuf

Will they ever be updated? It was pretty difficult for me to find this page as a first time user. Maybe even just a notice on the docs that they're outdated?

TylerBarnes avatar Sep 25 '18 23:09 TylerBarnes

ping @ncoden

Who is currently maintaining this project?

DanielRuf avatar Sep 26 '18 04:09 DanielRuf

I think that is the root issue. The maintenance of the project seems to be the main question.

On Wed, Sep 26, 2018 at 12:48 AM Daniel Ruf [email protected] wrote:

ping @ncoden https://github.com/ncoden

Who is currently maintaining this project?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zurb/foundation-emails/issues/540#issuecomment-424583571, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnKJDmpszODfasw-NjQ8FszDG5P-Th0ks5uewcEgaJpZM4JXKJu .

davehoran avatar Sep 26 '18 11:09 davehoran

Ran into this problem as well. Is this project dead? Seems like a pretty blatant issue when code doesn't work when you do every instruction from the docs to the letter and it does not produce the expected results.

BAM5 avatar Feb 08 '19 06:02 BAM5

It does work after updating gulpfile with two things.

First is pages function around line 55:, you need to pass the src/data directory to panini, by modifying the function to: (but you already know that)

function pages() {
  return gulp.src(['src/pages/**/*.html', '!src/pages/archive/**/*.html'])
    .pipe(panini({
      root: 'src/pages',
      layouts: 'src/layouts',
      partials: 'src/partials',
      helpers: 'src/helpers',
      data: 'src/data'
    }))
    .pipe(inky())
    .pipe(gulp.dest('dist'));
}

Second more important thing is to add panini.refresh function call in watch() function. See code below.

Edit function watch() and modify it to:

function watch() {
  gulp.watch('src/pages/**/*.html').on('all', gulp.series(pages, inline, browser.reload));
  gulp.watch(['src/layouts/**/*', 'src/partials/**/*']).on('all', gulp.series(panini.refresh, resetPages, pages, inline, browser.reload));
  gulp.watch(['../scss/**/*.scss', 'src/assets/scss/**/*.scss']).on('all', gulp.series(panini.refresh, resetPages, sass, pages, inline, browser.reload));
  gulp.watch('src/assets/img/**/*').on('all', gulp.series(images, browser.reload));
  gulp.watch('src/data/*').on('all', gulp.series(panini.refresh, resetPages, sass, pages, inline, browser.reload));
}

You can then access the variable everywhere by typing: {{ config.object.field }} -- the spaces after {{ and before }} are required!

example content of data/src/config.yml (notice the config in above variable reference and config.yml - those names needs to match!)

object: {
   field: "examplevalue"
}

We added a watch on the data files (which unfortunately doesn't work). If you change the content of yaml file you will have to quit the watch and start it again - it bugs out on [09:31:54] Starting 'bound '...

versedi avatar May 20 '19 07:05 versedi

It is not serious, the issue opened in 2016!!!

dkulakov avatar Dec 11 '19 12:12 dkulakov

Hi @dkulakov ,

we are currently working on Foundation Sites. We will come to Foundation Emails when we find the needed time to make new releases and update the docs.

Please keep in your mind that we do this in our free time.

DanielRuf avatar Dec 11 '19 12:12 DanielRuf

Hi @DanielRuf , wow sorry, I don't know it!

Thank you for a great job!

dkulakov avatar Dec 11 '19 12:12 dkulakov

We added a watch on the data files (which unfortunately doesn't work). If you change the content of yaml file you will have to quit the watch and start it again - it bugs out on [09:31:54] Starting 'bound '...

@versedi I noticed you used panin.refresh and resetPages in your gulp.watch. Just remove the first one and it should work: gulp.watch('src/data/*').on('all', gulp.series(resetPages, sass, pages, inline, browser.reload));

elcaptain avatar Dec 13 '19 17:12 elcaptain