ERB Creating Templates with ASP pages

I’ve been working on utilizing Chef from Opscode lately. One of the awesome features is the ability to create templates. A template of a file utilizes ERB for any customization. But what if you are creating template of an ASP page? ERB and ASP use very similar code tags. The following example will cause an issue and chef will fail:

<%hdr="<%= @site_name %>"%>

My recipe is only passing in a variable of site_name. Chef has no clue how to inperpret anything else and the erb template creation fails. There’s a way around this:

<%%hdr="<%= @site_name %>"%>

Add the extra “%” so “<%%” will ignore the ASP code tag. And it will do exactly that, escape the <%, but what one needs to know, is that this will not produce expected results. In this case the entire line is processed and ignored until the closing tag. So the result after template creation is:

<%hdr="<%= @site_name %>"%>

To correct this one would hope that simply adding the closing tag the statement as such:

<%%hdr="%><%= @site_name %>"%>

After which, the template will be processed,,, kinda….:

<%hdr="%>The Botched Network" %>

NOT what I want it to do. After mucking around with this for a long time, I’m at a loss. I ended up storing the entire line that I needed into a variable. I relinquish my ERB learning for now…

Sources:

y u no worky

John T Skarbek

John T Skarbek
Im an Infrastructure Engineer at CA Technologies in the Agile Business Unit. Reading and using the latest and greatest of technology is what I want to be doing. Blogging is not something I do on any regular basis (and it shows).

Demonstrating Memory Behavior for AWS Lambda Function Freezing

AWS indicates that when a function is executed, there are some things that getleftover between runs. The execution environment, which AW...… Continue reading

Openshift v3 Deployment Strategy

Published on April 23, 2016

Haproxy URL Rewrite Logging Double Take

Published on May 29, 2015