View Full Version : Makefile that user cat to load html and sed to replace

10-10-2012, 09:55 AM

Long time lurker but first time poster. I have a Makefile question and wasn't sure where to post the question but so I hope I picked the right category.

I'm working with backbone templates and have split my html in multiple files.
The index files includes this {template} text. I'm planing to use tha Makefile to load the text from multiple HTML files and replace the {template} variable with the content from those files.

My HTML files looks like this:

<a href='#'>my link</a>


Then I have a makefile that looks like such:

$(eval data := $(shell cat "file.html"))
sed -i '' 's/$({template})/$(data)/' index.html

The sed code works lika a charm and it replaces it with the data value if I force it to have text, but the cat breaks and gives me an 'Error 1'

I've tried both...
$(eval data := $(shell grep -nr file.html))
$(eval data := $(shell cat "file.html"))

They both fail when they reach <, >, ", ' or #.
I've not yet figured out how to load the html data into the variable.

So I'm looking for guidance from you guys and girl.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum