Replace vars in a path

@param  string $path
@param  array  $vars
@return string
558428
protected function _templatePath($path, array $vars = array())
    {
        if (strpos($path, '{') !== false) {
            preg_match_all('#\{\$([_a-z0-9]*)\}#i', $path, $matches);
            if (!empty($matches[1])) {
                foreach ($matches[1] as $var) {
                    $path = str_replace('{$' . $var . '}', isset($vars[$var]) ? $vars[$var] : null, $path);
                }
            }
        }
        return $path;
    }
1154902
protected function _relativizePath($path)
    {
        $plugins = Plugin::loaded();
        $index = array_search('AssetCompress', $plugins);
        unset($plugins[$index]);

        foreach ($plugins as $plugin) {
            $pluginPath = Plugin::path($plugin) . 'webroot';
            if (strpos($path, $pluginPath) === 0) {
                return str_replace($pluginPath, '/' . Inflector::underscore($plugin), $path);
            }
        }
        $path = str_replace(WWW_ROOT, '/', $path);

        return str_replace(DS, '/', $path);
    }
619986
static public function interpolate($str, array $vars) {
        $keys = array_keys($vars);
        $vals = array_values($vars);
        // surround keys by "%"
        array_walk(
            $keys, function (&$s) {
                $s = '%' . $s . '%';
            }
        );
        $str = str_replace($keys, $vals, $str);
        return $str;
    }
1298065
protected function templateVars($file, $vars)
    {
        $start = $this->delimiter[0];
        $end = $this->delimiter[1];

        foreach ($vars as $var) {
            $replace = $start . $var . $end;
            if (in_array($var, $this->vars)) {
                File::put($file, str_replace($replace, $this->$var, File::get($file)));
            }
        }
    }
1362299
public function url($path, $slashes = false)
    {
        $path = ($slashes !== false) ? explode('/', $path) : array($path);
        foreach ($path as $key => $value) {
            $path[$key] = URLify::filter($value);
        }

        return implode('/', $path);
    }
479824
public function getMatch($path)
    {
        $routeMatch = $this->mux->dispatch($path);
        if ($routeMatch) {
            $routes = $this->routes->getByOptionKeyValue('id', isset($routeMatch[3]['id']) ? $routeMatch[3]['id'] : '');
            if ($route = $routes->getFirst()) {
                $route->pathVars = isset($routeMatch[3]['vars']) ? $routeMatch[3]['vars'] : [];
            }
            return $route;
        }
    }
181036
public VarDefBuilder varDefAtPath( String[] path)
    {
    VarDefBuilder varDefBuilder = null;
    if( path != null && path.length > 0)
      {
      String varDefName = path[ path.length - 1];
      VarSetBuilder parentBuilder = varSetAtPath( Arrays.copyOfRange( path, 0, path.length - 1));
      if( parentBuilder != null)
        {
        varDefBuilder = parentBuilder.varDefAtPath( varDefName);
        }
      else
        {
        VarDef varDef = new VarDef( varDefName);
        functionInputDef_.addVarDef( varDef);
        varDefBuilder = new VarDefBuilder( varDef);
        }
      }

    return varDefBuilder;
    }
832238
private function setCovertVars(array $vars = [])
    {
        $this->setExt($vars['ext']);
        $this->capsule['ext'] = $vars['ext'];
        $this->setFilePath($vars['filepath']);
        $this->capsule['filepath'] = $vars['filepath'];
    }
69996
public function replace($path, $key, $value) {
        $path = str_replace(s('{%s}', $key), $value, $path);

        return $path;
    }
227071
function expandPath (path, replacements) {
  return R.toPairs(replacements).reduce((path, [key, value]) => path.replace(`{${key}}`, value), path)
}
458655
public static function unixslash(&$path) {
		if (\is_array($path)) {
			foreach ($path as $k=>$v) {
				static::unixslash($path[$k]);
			}
		}
		else {
			cast::string($path, true);

			$path = \str_replace('\\', '/', $path);
			$path = \str_replace('/./', '//', $path);
			$path = \preg_replace('/\/{2,}/u', '/', $path);
		}
	}
1118047
def _replace_path(self, path):
        
        if path in self._field_to_key:
            return self._field_to_key[path]
        next_key = "#f%d" % self._next_field
        self._next_field += 1
        self._field_to_key[path] = next_key
        self._fields[next_key] = path
        return next_key
1191533
protected function replaceFileContent($path, array $headers)
    {
        $content = $this->files->get($path);
        $this->files->put($path, str_replace([
            'DummyNamespace',
            'DummyAutoload',
            'dummy_path'
        ], [
            $this->getNamespace($headers['plugin_namespace']),
            $this->getAutoloadNamespace($headers['plugin_namespace']),
            $this->getPluginPath()
        ], $content), true);
    }
1283437
def _subst_vars(path, local_vars):
    
    def _replacer(matchobj):
        name = matchobj.group(1)
        if name in local_vars:
            return local_vars[name]
        elif name in os.environ:
            return os.environ[name]
        return matchobj.group(0)
    return _VAR_REPL.sub(_replacer, path)
1055569
public function block($path, $vars = [])
    {
        if ($path[0] !== '@' && strpos($path, '/') === false) {
            $path = "@views/Blocks/$path";
        }

        $this->_render($path, $vars, true);
    }
151826
private function matchVariableRouteChunk($path, $variableRoutes)
    {
        $numGroups = 0;

        /** @var Route[] $routes */
        $routes   = [];
        $pattern   = '';
        foreach ($variableRoutes as $route) {
            $numVariables = $route->getParameterCount();
            $pattern .= '|' . $route->getRegexp();
            if ($numVariables < $numGroups && !isset($routes[ $numVariables ])) {
                $routes[ $numVariables ] = $route;
            } else {
                $numGroups = max($numGroups, $numVariables);
                $pattern .= str_repeat('()', $numGroups - $numVariables);
                $routes[ $numGroups++ ] = $route;
            }
        }
        if (!preg_match('#^(?' . $pattern . ')$#', $path, $matched)) {
            return false;
        }
        //Remove the whole match
        array_shift($matched);
        $route = $routes[ count($matched) ];

        $parameterNames = $route->getParameterNames();
        //get the elements of $matched that are actually parameters
        $parameters = array_intersect_key($matched, $parameterNames);
        $matchedParams = array_combine($parameterNames, $parameters);

        return new Match($route, $matchedParams);
    }
962946
public static function strFindAndReplaceAll($vars = array(), $str)
    {
        if (array_count_values($vars) > 0){
            foreach ($vars as $key => $val) {
                for ($i = substr_count($str, $key); $i > 0; $i--) {
                    $str = \WebCMS\Helpers\SystemHelper::strlReplace($key, $val, $str);
                }
            }
        }
        return $str;
    }