public function getLayout($data = null) {
    $layout = null;

    // 1) Check the passed in data
    if (is_array($data) && array_key_exists(self::LAYOUT_KEY, $data)) {
      $layout = $data[self::LAYOUT_KEY];
      unset($data[self::LAYOUT_KEY]);
    }

    // 2) Check the data on the View
    if ($this->has(self::LAYOUT_KEY)) {
      $layout = $this->get(self::LAYOUT_KEY);
      $this->remove(self::LAYOUT_KEY);
    }

    // 3) Check the Slim configuration
    if (is_null($layout)) {
      $app = Slim::getInstance();
      if (isset($app)) {
        $layout = $app->config(self::LAYOUT_KEY);
      }
    }

    // 4) Use the default layout
    if (is_null($layout)) {
      $layout = self::DEFAULT_LAYOUT;
    }

    return $layout;
  }