5

If I want to create a block of html code that displays if a boolean value in mason is true is there a way to do this without using print to print each line of the html code? i.e. is there a way to do something like this

<% if($boolean) { %>
<li>
<a href='http://somesite.com'>link</a>
</li>
<% } %>

instead of

<%perl>
if($boolean) {
print "<li>";
print "<a href='http://somesite.com'>link</a>";
print "</li>";
}
</%perl>
thurmc
  • 495
  • 1
  • 8
  • 29
  • 3
    I found out the way to do this for anyone interested is by using % at the start of the line instead of surrounding the conditional start and end with <% %>. I'm posting answer in comments because I am a new user and need to wait 8 hours before answering my own question – thurmc May 06 '11 at 21:56

1 Answers1

3

As you mention in your comment, you can:

% if($boolean) {
<li>
<a href='http://somesite.com'>link</a>
</li>
% }
clt60
  • 62,119
  • 17
  • 107
  • 194