/** * {@inheritdoc} */ public function render(Slide $slide) { $lines = explode("\n", str_replace("\r", '', $slide->content)); $out = []; foreach ($lines as $line) { if (0 === strpos($line, self::COMMAND_PREFIX)) { $command = substr($line, strlen(self::COMMAND_PREFIX)); list($commandName, $commandParams) = explode(' ', $command, 2); if ($this->commandHandler->hasCommand($commandName)) { $line = $this->commandHandler->execute($commandName, new CommandParams($commandParams), $this->executionContext); } } $out[] = $line; } return implode("\n", $out); }
$hbs->addHelper('count', function (HbsTemplate $template, HbsContext $context, $args, $source) { return count($context->get($args)); }); $hbs->addHelper('join', function (HbsTemplate $template, HbsContext $context, $args, $source) { $matches = []; if (preg_match("#'([^']+)' (.+)#", $args, $matches)) { list(, $separator, $input) = $matches; $out = []; foreach ((array) $context->get($input) as $value) { $context->push($value); $out[] = $template->render($context); $context->pop(); } return implode($separator, $out); } return ''; }); return $hbs; }), 'Bigwhoop\\Trumpet\\Commands\\CommandExecutionContext' => DI\object(), 'Bigwhoop\\Trumpet\\Commands\\CommandHandler' => DI\factory(function (DIC $c) { $handler = new CommandHandler(); $handler->registerCommand($c->get('Bigwhoop\\Trumpet\\Commands\\CodeCommand')); $handler->registerCommand($c->get('Bigwhoop\\Trumpet\\Commands\\ExecCommand')); $handler->registerCommand($c->get('Bigwhoop\\Trumpet\\Commands\\IncludeCommand')); $handler->registerCommand($c->get('Bigwhoop\\Trumpet\\Commands\\ImageCommand')); $handler->registerCommand($c->get('Bigwhoop\\Trumpet\\Commands\\WikiCommand')); return $handler; }), 'PhpParser\\PrettyPrinterAbstract' => DI\object('\\PhpParser\\PrettyPrinter\\Standard'), 'PhpParser\\Lexer' => DI\object('PhpParser\\Lexer\\Emulative'), 'PhpParser\\ParserAbstract' => DI\object('PhpParser\\Parser')->constructor(DI\link('PhpParser\\Lexer')), 'PhpParser\\NodeTraverserInterface' => DI\object('PhpParser\\NodeTraverser')->method('addVisitor', DI\link('PhpParser\\NodeVisitor\\NameResolver'))]; $builder = new DI\ContainerBuilder(); $builder->addDefinitions(new DI\Definition\Source\ArrayDefinitionSource($definitions)); //$builder->useAnnotations(false); return $builder->build();