CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Computer Programming (http://www.codingforums.com/forumdisplay.php?f=21)
-   -   Makefile that user cat to load html and sed to replace (http://www.codingforums.com/showthread.php?t=275990)

bmson 10-10-2012 08:55 AM

Makefile that user cat to load html and sed to replace
 
Hi,

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:

file.html
<div>
<a href='#'>my link</a>
</div>

index.html
<body>
{template}
</body>


Then I have a makefile that looks like such:

Makefile
include:
$(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.


All times are GMT +1. The time now is 04:35 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.