Skip to content

Replaced output is mangled #17

@davidjost

Description

@davidjost

I am using gulp-token-replace in my pug files:

my JSON:

{
  "title" : "title",
  "headline" : "Headline 1"
}

My Pug:

section
  h2 {{title}}

Now with gulp I compile the pug and make sure that token-replace starts only after pug is finished. The output is this:

<section>
  <h2>title</h2>
</section>ion>

Somehow token-replace adds the stuff after the </section>.

Strangely this does not happen when I run the gulp tasks one after the other by hand.

Terminal tells me that the pug task has finished when token-replace has started, so this should not happen.

My Gulpfile:

// wait function to make sure tasks are finished before the next one starts
function wait(ms){
   var start = new Date().getTime();
   var end = start;
   while(end < start + ms) {
     end = new Date().getTime();
  }
}

gulp.task("pug", function() {
  return gulp.src(activeProject + "*.pug")
  .pipe(pug({
    pretty: true
  }))
  .pipe(gulp.dest(activeProject + "build/"))
  , wait(500)
});

gulp.task("token-replace", function(){
  var config = require(activeProject + "json/data.json");
  return gulp.src([activeProject + "build/*.html"])
    .pipe(replace({global: config}))
    .pipe(gulp.dest("build/"))
});

gulp.task("build-html", ["pug", "token-replace"]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions