D
D
Denis Bogdanov2016-03-04 09:29:36
css
Denis Bogdanov, 2016-03-04 09:29:36

How to include styles from a specific directory in jade?

There is a need during development to include styles in a jade file from a certain directory, the order of including styles does not matter, because. styles are independent of each other. You need something like a loop that would run through the directory, get the names of the files and create links to them in jade. There is a solution?
Something like this, but how to get this list?

-list = ['one', 'two', 'three']
each item in list
      link(rel="stylesheet", href=item)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lenar Fattakhov, 2016-03-04
@den-bogdanov

Since you are using gulp-jade
1) Variables can be passed to the template like this

jade({
  locals: {list: your_array}
})

2) You can get a list of files in a directory using the readdir method of the fs module. For example, like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question