private function loadRouteForAsset(RouteCollection $routes, AssetInterface $asset, $name, $pos = null)
    {
        $defaults = array(
            '_controller' => 'assetic.controller:render',
            'name'        => $name,
            'pos'         => $pos,
        );
        $requirements = array();

        // remove the fake front controller
        $pattern = str_replace('_controller/', '', $asset->getTargetPath());

        if ($format = pathinfo($pattern, PATHINFO_EXTENSION)) {
            $defaults['_format'] = $format;
        }

        $route = '_assetic_'.$name;
        if (null !== $pos) {
            $route .= '_'.$pos;
        }

        foreach ($asset->getVars() as $var) {
            if (empty($this->varValues[$var])) {
                throw new \UnexpectedValueException(sprintf('The possible values for the asset variable "%s" are not known', $var));
            }

            $values = array();

            foreach ($this->varValues[$var] as $value) {
                $values[] = preg_quote($value, '#');
            }

            $requirements[$var] = implode('|', $values);
        }

        $routes->add($route, new Route($pattern, $defaults, $requirements));
    }