Skip to content

Instantly share code, notes, and snippets.

@rpocklin
Created July 26, 2013 07:51
Show Gist options
  • Save rpocklin/6087040 to your computer and use it in GitHub Desktop.
Save rpocklin/6087040 to your computer and use it in GitHub Desktop.
Scala feature toggles
@(toggle: String)(enabledContent: Any)(disabledContent: Any)
@import play.api._
@defining(Play.current.configuration.getBoolean("toggles." + toggle)) { toggleValue =>
@toggleValue match {
case Some(toggleEnabled) => {
@if(toggleEnabled) {
@enabledContent
} else {
@disabledContent
}
}
case None => {
<h1> Error invalid toggle specified: @toggle</h1>
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment