Makefile that uses cat to store html in shell var

Discussion in 'Programming' started by bmson, Oct 10, 2012.

  1. #1
    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.
     
    bmson, Oct 10, 2012 IP
  2. _MasterOfPuppets_

    _MasterOfPuppets_ Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this statement:
    VARIABLE=`cat FILE`
     
    _MasterOfPuppets_, Oct 12, 2012 IP