Sayanee
Sayanee

Reputation: 5167

jade output path directory using the makefile

I'm using the makefile to compile jade file into html. How should I amend this line with jade options so that my ultimate index.html is one level up in the directory and not in the same folder as the jade files? Currently, I'm having the index.html inside the folder jade.

%.html: %.jade
    jade < $< --out $< --path $< --pretty > $@

I would want the folder structure to be like this:

|--jade
   |--index.jade
|--index.html

I do not want my folder structure to be like this:

|--jade
   |--index.jade
   |--index.html

my entire makefile includes:

JADE = $(shell find jade/*.jade)
HTML = $(JADE:.jade=.html)

all: $(HTML)

%.html: %.jade
    jade < $< --out $< --path $< --pretty > $@

clean:
    rm -f $(HTML)

.PHONY: clean

Upvotes: 0

Views: 853

Answers (1)

Beta
Beta

Reputation: 99124

If you want all html files to go into the directory one level up:

JADE = $(shell find jade/*.jade)
HTML = $(patsubst jade/%.jade, %.html, $(JADE))

all: $(HTML)

%.html: jade/%.jade
    jade < $< --out $< --path $< --pretty > $@

If you want index.html to go into the upper directory, but all other html files to go into jade/:

JADE = $(shell find jade/*.jade)
HTML := $(JADE:.jade=.html)
HTML := $(subst jade/index.html, index.html, $(HTML))

all: $(HTML)

%.html: %.jade
    jade < $< --out $< --path $< --pretty > $@

index.html: jade/index.jade
    jade < $< --out $< --path $< --pretty > $@

If there are many html files which should go into the upper directory, you can construct the HTML list any way you like, and then:

%.html: %.jade
    jade < $< --out $< --path $< --pretty > $@

%.html: jade/%.jade
    jade < $< --out $< --path $< --pretty > $@

Upvotes: 2

Related Questions