Fills up template string with placed variables.

@return mixed
161030
public function produce()
    {
        $result = $this->template;
        $regex = sprintf('~%s([\w\.]+)%s~m', $this->placeholderStart, $this->placeholderEnd);

        $matched = preg_match_all($regex, $result, $matches, PREG_SET_ORDER);
        if (!$matched) {
            return $result;
        }

        foreach ($matches as $match) { // fill in placeholders
            $placeholder = $match[1];
            $value = $this->vars;
            foreach (explode('.', $placeholder) as $segment) {
                if (is_array($value) && array_key_exists($segment, $value)) {
                    $value = $value[$segment];
                } else {
                    continue 2;
                }
            }

            $result = str_replace($this->placeholderStart . $placeholder . $this->placeholderEnd, $value, $result);
        }
        return $result;
    }
1257446
public function getTemplate() : ?string 
    {
        if ( ! $this->hasTemplate()) {
            $this->setTemplate($this->getDefaultTemplate());
        }
        return $this->template;
    }
1053145
public static function vars()
    {
        if (func_num_args() === 0)
        {
            return null;
        }

        $variables = func_get_args();
        $output = [];
        foreach ($variables as $var)
        {
            $output[] = VarDumper::dump($var);
        }

        return implode("\n", $output);
    }
1088101
public function getVariables() 
	{
		return array(
			'use_wysiwyg' => $this->wysiwyg,
			'fields' => $this->show,
			'labels' => $this->labels,
			'data' => $this->data,
			'errors' => $this->errors,
			'holders' => $this->holders);
	}
871778
public function getVariables() 
	{
		$this->attributes['class'] = 'eden-field-mask';
		if(isset($this->attributes['class'])) {
			$this->attributes['class'] = trim($this
			->attributes['class'].' eden-field-mask');
		}
		
		$variables = parent::getVariables();
		
		$variables['pattern'] = $this->pattern;
		$variables['loaded'] = self::$loaded;
		
		self::$loaded = true;
		
		return $variables;
	}
300330
protected function locate_template() : string {

		if ( isset( $this->template ) ) {
			return $this->template;
		}

		$templates = [];

		if ( ! empty( $this->name ) ) {
			$templates[] = "{$this->args['dir']}/{$this->slug}-{$this->name}.php";
		}

		$templates[] = "{$this->args['dir']}/{$this->slug}.php";

		$this->template = locate_template( $templates );

		if ( 0 !== validate_file( $this->template ) ) {
			$this->template = '';
		}
		return $this->template;

	}
703846
public function variables() : array
    {
        return [
            'placeholder' => $this->placeholder,
            'icon'        => $this->icon,
            'type'        => $this->type,
            'group'       => $this->filter->group,
        ];
    }
871120
protected function fillValuesArray()
    {
        $this->values['j'] = $this->day;
        $this->values['d'] = str_pad($this->day, 2, 0, STR_PAD_LEFT);
        $this->values['D'] = static::$translation->getShortDays()[$this->date->dayOfWeek];
        $this->values['l'] = static::$translation->getDays()[$this->date->dayOfWeek];

        $this->values['n'] = $this->month;
        $this->values['m'] = str_pad($this->month, 2, 0, STR_PAD_LEFT);
        $this->values['M'] = static::$translation->getHijriMonths()[$this->month - 1];
        $this->values['F'] = static::$translation->getHijriMonths()[$this->month - 1];

        $this->values['o'] = $this->year;
        $this->values['y'] = substr($this->year, 0, 2);
        $this->values['Y'] = str_pad($this->year, 4, 0, STR_PAD_LEFT);

        $this->values['a'] = $this->date->hour >= 12 ? static::$translation->getPeriods()[1] : static::$translation->getPeriods()[0];
        $this->values['A'] = strtoupper($this->date->hour >= 12 ? static::$translation->getPeriods()[1] : static::$translation->getPeriods()[0]);

        $this->fillCarbonValues();

        return $this;
    }
33722
public function getParameters() {
		$filledvars = array();
		foreach (get_object_vars($this) as $name => $value) {
			if ($value) {
				$filledvars[$name] = (string)$value;
			}
		}

		return $filledvars;
	}
640246
protected function buildVariableHeader()
    {
        $buffer = "";
        $buffer .= chr($this->session_present);
        $buffer .= chr($this->return_code);
        return $buffer;
    }
647325
protected function parse_template() {

        if (empty($this->params)) {
            $this->params = array();
            if (isset($_SERVER['PATH_INFO']) && !empty($_SERVER['PATH_INFO'])) {
                $path = explode('/', $_SERVER['PATH_INFO']);
                $parts = explode('/', $this->get_template());
                for ($i = 0; $i < count($parts); $i++) {
                    if ((substr($parts[$i], 0, 1) == '{') && (substr($parts[$i], -1) == '}')) {
                        $value = '';
                        if ($i < count($path)) {
                            $value = $path[$i];
                        }
                        $this->params[substr($parts[$i], 1, -1)] = $value;
                    }
                }
            }
        }

        return $this->params;

    }
1105992
public function getCode()
    {
        $locator = new TemplateLocator(new FileLocator($this->getTemplateDirs()));
        $templateNameParser = new TemplateNameParser();
        $loader = new FilesystemLoader($locator, $templateNameParser);
        $twig = new \Twig_Environment(
            $loader,
            array(
                'autoescape' => false,
                'strict_variables' => true,
                'debug' => true,
                'cache' => $this->getGenerator()->getTempDir(),
            )
        );

        $this->addTwigExtensions($twig, $loader);
        $this->addTwigFilters($twig);
        $template = $twig->loadTemplate($this->getTemplateName());

        $variables = $this->getVariables();
        $variables['builder'] = $this;

        return $template->render($variables);
    }
1148557
private static function ReplaceVars(){
            $oThis = self::CreateInstanceIfNotExists();

            $aP = array();
            $iOffset = 0;

            while(preg_match('/(\{\$(.*?)\})/i', $oThis->sBuffer, $aMatches, PREG_OFFSET_CAPTURE, $iOffset)){
                $mVar = $aMatches[2][0];

                if(Storage::Has($mVar)){
                    $mTo = Storage::Get($mVar);

                    if(is_bool($mTo))
                        $mTo = ($mTo) ? "true" : "false";

                    $mTo = html_entity_decode($mTo, ENT_NOQUOTES/*, Config::Read("l10n.charset")*/);
                    $oThis->sBuffer = str_replace($aMatches[0][0], $mTo, $oThis->sBuffer);
                }

                $iOffset = $aMatches[0][1]+strlen($aMatches[0][0]);
            }
        }
149846
private function encapsVar() {
    static $offset_types = [T_STRING, T_NUM_STRING, T_VARIABLE];
    $node = new StringVariableNode();
    if ($this->tryMatch(T_DOLLAR_OPEN_CURLY_BRACES, $node)) {
      if ($this->tryMatch(T_STRING_VARNAME, $node)) {
        if ($this->tryMatch('[', $node)) {
          $node->addChild($this->expr());
          $this->mustMatch(']', $node);
        }
      }
      else {
        $node->addChild($this->expr());
      }
      $this->mustMatch('}', $node);
      return $node;
    }
    elseif ($this->tryMatch(T_CURLY_OPEN, $node)) {
      $node->addChild($this->variable());
      $this->mustMatch('}', $node);
      return $node;
    }
    elseif ($this->mustMatch(T_VARIABLE, $node)) {
      if ($this->tryMatch('[', $node)) {
        if (!in_array($this->currentType, $offset_types)) {
          throw new ParserException(
            $this->filename,
            $this->iterator->getLineNumber(),
            $this->iterator->getColumnNumber(),
            'expected encaps_var_offset (T_STRING or T_NUM_STRING or T_VARIABLE)');
        }
        $node->addChild($this->tryMatchToken($offset_types));
        $this->mustMatch(']', $node);
      }
      elseif ($this->tryMatch(T_OBJECT_OPERATOR, $node)) {
        $this->mustMatch(T_STRING, $node);
      }
      return $node;
    }
    throw new ParserException(
      $this->filename,
      $this->iterator->getLineNumber(),
      $this->iterator->getColumnNumber(),
      'expected encaps variable');
  }
1020467
public function getVariables() 
	{
		$variables = parent::getVariables();
		
		$loaded = self::$loaded;
		self::$loaded = true;
		
		$variables['loaded'] = $loaded;
		
		return $variables;
	}
148474
protected function _getTemplateVars() {
        $vars = array(
            'default_backend'   => $this->_getDefaultBackend(),
            'admin_backend'     => $this->_getAdminBackend(),
            'admin_frontname'   => $this->_getAdminFrontname(),
            'normalize_host_target' => $this->_getNormalizeHostTarget(),
            'url_base_regex'    => $this->getBaseUrlPathRegex(),
            'allowed_hosts_regex'   => $this->getAllowedHostsRegex(),
            'url_excludes'  => $this->_getUrlExcludes(),
            'get_param_excludes'    => $this->_getGetParamExcludes(),
            'get_param_ignored' => $this->_getIgnoreGetParameters(),
            'default_ttl'   => $this->_getDefaultTtl(),
            'enable_get_excludes'   => ($this->_getGetParamExcludes() ? 'true' : 'false'),
            'enable_get_ignored' => ($this->_getIgnoreGetParameters() ? 'true' : 'false'),
            'send_unmodified_url' => ($this->_sendUnModifiedUrlToBackend() ? 'true' : 'false'),
            'debug_headers' => $this->_getEnableDebugHeaders(),
            'grace_period'  => $this->_getGracePeriod(),
            'force_cache_static'    => $this->_getForceCacheStatic(),
            'simple_hash_static'    => $this->_getSimpleHashStatic(),
            'generate_session_expires'    => $this->_getGenerateSessionExpires(),
            'generate_session'    => $this->_getGenerateSession(),
            'generate_session_start'    => $this->_getGenerateSessionStart(),
            'generate_session_end'    => $this->_getGenerateSessionEnd(),
            'static_extensions' => $this->_getStaticExtensions(),
            'static_ttl'    => $this->_getStaticTtl(),
            'url_ttls'      => $this->_getUrlTtls(),
            'enable_caching'    => $this->_getEnableCaching(),
            'crawler_acl'   => $this->_vcl_acl('crawler_acl',
                $this->_getCrawlerIps()),
            'esi_cache_type_param'  =>
                Mage::helper('turpentine/esi')->getEsiCacheTypeParam(),
            'esi_method_param'  =>
                Mage::helper('turpentine/esi')->getEsiMethodParam(),
            'esi_ttl_param' => Mage::helper('turpentine/esi')->getEsiTtlParam(),
            'secret_handshake'  => Mage::helper('turpentine/varnish')
                ->getSecretHandshake(),
            'crawler_user_agent_regex'  => $this->_getCrawlerUserAgents(),
            // 'lru_factor'    => $this->_getLruFactor(),
            'debug_acl'     => $this->_vcl_acl('debug_acl',
                $this->_getDebugIps()),
            'custom_c_code' => file_get_contents(
                $this->_getVclTemplateFilename(self::VCL_CUSTOM_C_CODE_FILE) ),
            'esi_private_ttl'   => Mage::helper('turpentine/esi')
                ->getDefaultEsiTtl(),
        );

        if ((bool) Mage::getStoreConfig('turpentine_vcl/urls/bypass_cache_store_url')) {
            $vars['allowed_hosts'] = $this->_vcl_sub_allowed_hosts_regex();
        }

        if (Mage::getStoreConfig('turpentine_vcl/normalization/encoding')) {
            $vars['normalize_encoding'] = $this->_vcl_sub_normalize_encoding();
        }
        if (Mage::getStoreConfig('turpentine_vcl/normalization/user_agent')) {
            $vars['normalize_user_agent'] = $this->_vcl_sub_normalize_user_agent();
        }
        if (Mage::getStoreConfig('turpentine_vcl/normalization/host')) {
            $vars['normalize_host'] = $this->_vcl_sub_normalize_host();
        }
        if (Mage::getStoreConfig('turpentine_vcl/normalization/cookie_regex')) {
            $vars['normalize_cookie_regex'] = $this->_getNormalizeCookieRegex();
        }
        if (Mage::getStoreConfig('turpentine_vcl/normalization/cookie_target')) {
            $vars['normalize_cookie_target'] = $this->_getNormalizeCookieTarget();
        }

        if (Mage::getStoreConfig('turpentine_vcl/maintenance/enable')) {
            // in vcl_recv set the allowed IPs otherwise load the vcl_error (v3)/vcl_synth (v4)
            $vars['maintenance_allowed_ips'] = $this->_vcl_sub_maintenance_allowed_ips();
            // set the vcl_error from Magento database
            $vars['vcl_synth'] = $this->_vcl_sub_synth();
        }

        if (Mage::getStoreConfig('turpentine_varnish/general/https_proto_fix')) {
            $vars['https_proto_fix'] = $this->_vcl_sub_https_proto_fix();
        }
        
        if (Mage::getStoreConfig('turpentine_varnish/general/https_redirect_fix')) {
            $vars['https_redirect'] = $this->_vcl_sub_https_redirect_fix();
            if (Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0' || Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.1') {
                $vars['vcl_synth'] = $this->_vcl_sub_synth_https_fix();
            }
        }

        foreach (array('', 'top') as $position) {
            $customIncludeFile = $this->_getCustomIncludeFilename($position);
            if (is_readable($customIncludeFile)) {
                $key = 'custom_vcl_include';
                $key .= ($position) ? '_'.$position : '';
                $vars[$key] = file_get_contents($customIncludeFile);
            }
        }

        return $vars;
    }
417045
private function getInsertFieldsString()
    {
        // Get field keys
        $fieldKeys = array_keys($this->fields);

        // Create placeholders
        $fieldsPlaceholders = array_map(function ($field) {
            return ':' . $field;
        }, $fieldKeys);

        // Return complete fields string
        return '(' . implode(',', $fieldKeys) . ') VALUES ('. implode(',', $fieldsPlaceholders) . ')';
    }