Segment fallbacks

Hi!

I’ve been playing around with the “renewed” segment-stuff in v16-rc.

I used Kenn Jacobsens great blog post as a starting point. I’m trying to understand if there is a way to provide a fallback value if the current segment does not have a value.

My current approach is something like:

  • Set default values on the view model
  • Set the VariationContext to the current segment (if any)
  • Extract values to the view model they have a value
  • Reset the VariationContext to the initial value

This is of course very hacky, I’m wondering if there’s a more elegant way to do this? Similar to how it works with language variants

@Model.Value("something", fallback: Fallback.YadaYada)

Cheers!