Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional tags in play 2.0 templates

I have a template with paramaters

@(title: Html, topbar: Html, nav: String = "")(content: Html)

I use the @title tag to set both a title for the page and a page header i.e.:

<div class="header">
<h1>@title</h1> 
</div>

However, Some pages I dont want to put a header/title in so i leave them blank and tried:

@if(title != {}){
    <div class="header">
    <h1>@title</h1> 
    </div>
}

But this does not work.. How would I achieve this?

Thanks

like image 370
Omar Wagih Avatar asked Sep 07 '12 17:09

Omar Wagih


1 Answers

You can pass null value in the controller, in actions that shouldn't use the title and then check if title != null

@if(title != null){
    <div class="header">
    <h1>@title</h1> 
    </div>
}
like image 100
biesior Avatar answered Oct 21 '22 11:10

biesior