erb syntaxes

198 views
Skip to first unread message

Choon Ming Goh

unread,
Sep 2, 2012, 11:31:19 PM9/2/12
to puppet...@googlegroups.com
Hi guys,

I'm trying to do the following in my template: 

  location <%= location %> {
    proxy_pass <%= proxy %>;
    <% if scope.lookupvar('nginx::resource::location::proxy_header') then
        scope.lookupvar('nginx::resource::location::proxy_header').each do |header| %>
    proxy_set_header <%= header %>
    <% end %>
  }

But i'm getting this error instead:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: compile error
/etc/puppet/modules/nginx/templates/vhost/vhost_location_proxy.erb:9: syntax error, unexpected $end, expecting kEND
; _erbout
         ^
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run

I've tried changing to 

<% if scope.lookupvar('nginx::resource::location::proxy_header') 
        scope.lookupvar('nginx::resource::location::proxy_header').each do |header| %>

and

<% if scope.lookupvar('nginx::resource::location::proxy_header') %>
        <% scope.lookupvar('nginx::resource::location::proxy_header').each do |header| %>

and

<% if scope.lookupvar('nginx::resource::location::proxy_header') then scope.lookupvar('nginx::resource::location::proxy_header').each do |header| %>

but none of these are working. Any pointers are definitely appreciated

Gonzalo Servat

unread,
Sep 3, 2012, 12:14:48 AM9/3/12
to puppet...@googlegroups.com
On Mon, Sep 3, 2012 at 1:31 PM, Choon Ming Goh <choonm...@gmail.com> wrote:
Hi guys,

I'm trying to do the following in my template: 

  location <%= location %> {
    proxy_pass <%= proxy %>;
    <% if scope.lookupvar('nginx::resource::location::proxy_header') then
        scope.lookupvar('nginx::resource::location::proxy_header').each do |header| %>
    proxy_set_header <%= header %>
    <% end %>

Not sure if this is it, but try adding another <% end %> as you have an "if" statement and a "do" block to close.

- Gonzalo

Choon Ming Goh

unread,
Sep 3, 2012, 5:03:00 AM9/3/12
to puppet...@googlegroups.com
Hey,

Thanks it works! Funny that it didnt work before this as I swore I tried it too. my luck maybe.
Reply all
Reply to author
Forward
0 new messages