Conditional tag templates in game 2.0

I have a template with options

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

I use the @title tag to set both the page title and the ie page title:

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

However, some pages on which I do not want to put a heading / heading, so I leave them blank and tried:

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

But that does not work. How can i achieve this?

thank

+5
source share
1 answer

You can pass the nullvalue in the controller, in actions that you should not use title, and then checktitle != null

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

All Articles