Skip to content

Instantly share code, notes, and snippets.

@warrenbuckley
Created April 27, 2015 19:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warrenbuckley/28243300b2907677a1fa to your computer and use it in GitHub Desktop.
Save warrenbuckley/28243300b2907677a1fa to your computer and use it in GitHub Desktop.
@{
//Obviously get header from umbraco value
var header = string.empty;
var mainHeader = Model.Content.GetPropertyValue<string>("mainHeader");
var secondaryHeader = Model.Content.GetPropertyValue<string>("secondaryHeader");
var nodeName = Model.Content.Name;
//Check if we have mainHeader value, fallback to secondaryHeader
header = !string.IsNullOrEmpty(mainHeader) : mainHeader ? secondaryHeader;
//Check again as the variable secondary header still could be null or empty string
//This time check header variable itself. If it's still emtpy or null fallback to nodename
header = !string.IsNullOrEmpty(header) : header ? nodeName;
}
<h1>@header</h1>
@bootnumlock
Copy link

okay, i see stacked ternaries then... right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment