original_string: private function compileTemplate($templatePath, $destinationPath, $data = null)
      {
          if ($data == null) {
              $data = $destinationPath;
              $destinationPath = null;
          }
          
          if (! isset($this->templates[$templatePath])) {
              $this->templates[$templatePath] = file_get_contents($templatePath);
          }
          
          $compiled = preg_replace_callback('/{{\s*([A-z0-9_-]+)\s*}}/', function ($matches) use ($data) {
              if (isset($data[$matches[1]])) {
                  return $data[$matches[1]];
              }
              
              return $matches[0];
          }, $this->templates[$templatePath]);
          
          if ($destinationPath) {
              file_put_contents($destinationPath, $compiled);
          }
          
          return $compiled;
      }
code: private function compileTemplate($templatePath, $destinationPath, $data = null)
      {
          if ($data == null) {
              $data = $destinationPath;
              $destinationPath = null;
          }
          
          if (! isset($this->templates[$templatePath])) {
              $this->templates[$templatePath] = file_get_contents($templatePath);
          }
          
          $compiled = preg_replace_callback('/{{\s*([A-z0-9_-]+)\s*}}/', function ($matches) use ($data) {
              if (isset($data[$matches[1]])) {
                  return $data[$matches[1]];
              }
              
              return $matches[0];
          }, $this->templates[$templatePath]);
          
          if ($destinationPath) {
              file_put_contents($destinationPath, $compiled);
          }
          
          return $compiled;
      }
code_tokens: private function compileTemplate ( $ templatePath , $ destinationPath , $ data = null ) { if ( $ data == null ) { $ data = $ destinationPath ; $ destinationPath = null ; } if ( ! isset ( $ this -> templates [ $ templatePath ] ) ) { $ this -> templates [ $ templatePath ] = file_get_contents ( $ templatePath ) ; } $ compiled = preg_replace_callback ( '/{{\s*([A-z0-9_-]+)\s*}}/' , function ( $ matches ) use ( $ data ) { if ( isset ( $ data [ $ matches [ 1 ] ] ) ) { return $ data [ $ matches [ 1 ] ] ; } return $ matches [ 0 ] ; } , $ this -> templates [ $ templatePath ] ) ; if ( $ destinationPath ) { file_put_contents ( $ destinationPath , $ compiled ) ; } return $ compiled ; }
docstring: Compile a template file.
  
  @param  string  $templatePath
  @param  string  $destinationPath
  @param  array|null  $data
  @return string
docstring_tokens: Compile a template file .