Skip to content

Instantly share code, notes, and snippets.

@samandmoore
Created January 31, 2012 14:02
Show Gist options
  • Save samandmoore/1710637 to your computer and use it in GitHub Desktop.
Save samandmoore/1710637 to your computer and use it in GitHub Desktop.
Umbraco v5 MacroParameters default value
@functions {
object MacroParamValueOrDefault(dynamic paramValue, object defaultValue = null)
{
if(string.IsNullOrEmpty(paramValue)) {
return defaultValue;
} else {
return paramValue;
}
}
}
@* usage... *@
@{
int x = Convert.ToInt32(MacroParamValueOrDefault(Model.MacroParameters.maxLevel, defaultValue: 8));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment