public function testMustache()
 {
     $this->assertEquals(Mustache::replace(" Hello {{ world }}", array('world' => 'world')), ' Hello world');
     $this->assertEquals(Mustache::replace(" Hello {{world}}", array('world' => 'world')), ' Hello world');
     $this->assertEquals(Mustache::replace(" Hello {{ world }}", array('no-world' => 'world')), ' Hello {{ world }}');
     $file = sprintf("%s/../fixtures/test.mustache", __DIR__);
     $this->assertEquals(Mustache::replaceFromFile($file, array('world' => 'world')), 'Hello world');
 }
 /**
  * @param OutputInterface $output
  * @param BundleMetadata  $bundleMetadata
  */
 protected function generateBundleFile(OutputInterface $output, BundleMetadata $bundleMetadata)
 {
     $file = sprintf('%s/Application%s.php', $bundleMetadata->getExtendedDirectory(), $bundleMetadata->getName());
     if (is_file($file)) {
         return;
     }
     $output->writeln(sprintf('  > generating bundle file <comment>%s</comment>', $file));
     $string = Mustache::replace($this->getBundleTemplate(), array('bundle' => $bundleMetadata->getName(), 'namespace' => $bundleMetadata->getExtendedNamespace()));
     file_put_contents($file, $string);
 }
 protected function writeSerializerFile(OutputInterface $output, BundleMetadata $bundleMetadata, $template, $destFile, $name)
 {
     if (is_file($destFile)) {
         $output->writeln(sprintf('   ~ <info>%s</info>', $name));
     } else {
         $output->writeln(sprintf('   + <info>%s</info>', $name));
         $string = Mustache::replace($template, array('name' => $name, 'namespace' => $bundleMetadata->getExtendedNamespace(), 'root_name' => strtolower(preg_replace('/[A-Z]/', '_\\0', $name))));
         file_put_contents($destFile, $string);
     }
 }
 /**
  * @param OutputInterface $output
  * @param BundleMetadata  $bundleMetadata
  */
 public function generateEntityRepositoryFiles(OutputInterface $output, BundleMetadata $bundleMetadata)
 {
     $output->writeln(' - Generating entity repository files');
     $names = $bundleMetadata->getOrmMetadata()->getEntityNames();
     foreach ($names as $name) {
         $dest_file = sprintf('%s/%sRepository.php', $bundleMetadata->getOrmMetadata()->getExtendedEntityDirectory(), $name);
         $src_file = sprintf('%s/Base%sRepository.php', $bundleMetadata->getOrmMetadata()->getEntityDirectory(), $name);
         if (!is_file($src_file)) {
             $output->writeln(sprintf('   ! <info>%sRepository</info>', $name));
             continue;
         }
         if (is_file($dest_file)) {
             $output->writeln(sprintf('   ~ <info>%sRepository</info>', $name));
         } else {
             $output->writeln(sprintf('   + <info>%sRepository</info>', $name));
             $string = Mustache::replace($this->getEntityRepositoryTemplate(), array('extended_namespace' => $bundleMetadata->getExtendedNamespace(), 'name' => $name, 'namespace' => $bundleMetadata->getNamespace()));
             file_put_contents($dest_file, $string);
         }
     }
 }