예제 #1
0
 /**
  * Copy per file.
  *
  * @param string $src     Source path.
  * @param string $dest    Destination path.
  * @param array  $replace Replace array.
  *
  * @return  void
  */
 protected function copyFile($src, $dest, $replace = array())
 {
     // Replace dest file name.
     $dest = SimpleTemplate::render($dest, $replace, $this->tagVariable);
     if (is_file($dest)) {
         $this->io->out('File exists: ' . $dest);
     } else {
         // Replace content
         $content = SimpleTemplate::render(file_get_contents($src), $replace, $this->tagVariable);
         if (File::write($dest, $content)) {
             $this->io->out('File created: ' . $dest);
         }
     }
 }
예제 #2
0
 /**
  * copyFile
  *
  * @param string $src
  * @param string $dest
  * @param array  $replace
  *
  * @return  void
  */
 protected function copyFile($src, $dest, $replace = array())
 {
     // Replace dest file name.
     $dest = SimpleTemplate::render($dest, $replace, $this->tagVariable);
     if (substr($dest, -4) == '.tpl') {
         $dest = substr($dest, 0, -4);
     }
     if (is_file($dest)) {
         $this->io->out('[<comment>File exists</comment>] ' . $dest);
     } else {
         $content = SimpleTemplate::render(file_get_contents($src), $replace, $this->tagVariable);
         if (File::write($dest, $content)) {
             $this->io->out('[<info>File created</info>] ' . $dest);
         }
     }
 }
예제 #3
0
 /**
  * Parse variable and replace it. This method is a simple template engine.
  *
  * Example: The {{ foo.bar.yoo }} will be replace to value of `$data['foo']['bar']['yoo']`
  *
  * @param   string $string The template to replace.
  * @param   array  $data   The data to find.
  * @param   array  $tags   The variable tags.
  *
  * @return  string Replaced template.
  *
  * @deprecated  3.0  Use SimpleTemplate::render() instead.
  */
 public static function parseVariable($string, $data = array(), $tags = array('{{', '}}'))
 {
     return SimpleTemplate::render($string, $data, $tags);
 }