Acacha\Llum\Compiler\RCFileCompiler::compile PHP Method

compile() public method

Compile the template using the given data.
public compile ( $template, $data ) : mixed
$template
$data
return mixed
    public function compile($template, $data)
    {
        foreach ($data as $key => $value) {
            $template = preg_replace("/\\\${$key}\\\$/i", $value, $template);
        }
        return $template;
    }

Usage Example

Example #1
0
 /**
  * init command.
  */
 public function init(InputInterface $input, OutputInterface $output)
 {
     try {
         $this->executeWizard($input, $output);
         $this->filesytem->overwrite((new LlumRCFile())->path(), $this->compiler->compile($this->filesytem->get($this->getStubPath()), $this->data));
     } catch (\Exception $e) {
         print_r($e->xdebug_message);
     }
 }
RCFileCompiler