On Sat, Aug 04, 2012 at 03:10:11AM -0700, danielt wrote: > Hi! > > I am trying to match a string in an ERB template but for what ever reason > it does not work. > > <% if has_variable?("apache2_phpmyadmin_url") && apache2_phpmyadmin_url != > "" then %> > ProxyPass /<%= apache2_phpmyadmin_url %>/ ! > <% end %> > > The conditional works on has_variable? but the != "" is not getting > evaluated. When the variable is set to "" than the Proxypass is set to / > instead of being left out. > > Any ideas what I am doing wrong? > > Best Regards, > > Dan
Are you sure the variable is an empty string? I just did a short test myself and your example does work for me. try to modify your ProxyPass line to ProxyPass /<%= apache2_phpmyadmin_url.inspect %>/ ! This way an empty string should appear as "" and you may find out that apache2_phpmyadmin_url does contain some spaces or is not a string at all. Sitenote: The documentation recommends to reference your variables as instance variables [1] to avoid nameclashes with ruby functions [2]. This way your template could look like this <% if @apache2_phpmyadmin_url and !@apache2_phpmyadmin_url.empty? -%> ProxyPass /<%= @apache2_phpmyadmin_url %>/ ! <% end -%> [1] http://docs.puppetlabs.com/guides/templating.html#referencing-variables [2] http://projects.puppetlabs.com/issues/14527 -Stefan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.