D
D
Denis Karakchiev2019-03-07 13:59:19
JSON
Denis Karakchiev, 2019-03-07 13:59:19

How to pass variables to sass from json file using gulp collector?

This is how I do with variables in json + twig (wish something like this)

"page": {
    "view": "mockup",
    "bg": "gradient",
    "buttons": "two"
  },

gulp.task('twig', function() {
  return gulp.src('app/**/*.twig').
      pipe(data(function(file) {
        return JSON.parse(fs.readFileSync('app/options.json'));
      })).
      pipe(twig()).
      pipe(gulp.dest('public'));
});

and use
{% include "layouts/contents/" ~ page.view ~ ".twig" %}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Karakchiev, 2019-04-03
@uokersam

In case anyone stumbles, here is the solution from my own stackoverflow question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question