- //Rename it
- if (rename($this->prefix.$output.'.new', $this->prefix.$output) === false) {
- throw new \Twig_Error_Syntax(sprintf('Unable to rename: %s to %s', $prefix.$output.'.new', $prefix.$output), $token->getLine(), $stream->getSourceContext());
+ //Send body with context set
+ return new Node([
+ //This define name in twig template by prepending $context['<name>'] = '<output>';
+ new SetNode(true, $ref, $value, $token->getLine(), $this->getTag()),
+ //The tag captured body
+ $body
+ ]);
+ }
+
+ /**
+ * Test for tag end
+ *
+ * @param Token token The \Twig\Token instance
+ *
+ * @return bool
+ */
+ public function testEndTag(Token $token) {
+ return $token->test(['end'.$this->getTag()]);
+ }
+
+ /**
+ * Get path from bundled file
+ *
+ * @param string file The bundled file path
+ * @param int lineno The template line where the error occurred
+ * @param Source source The source context where the error occurred
+ * @param \Exception prev The previous exception
+ *
+ * @return string The resolved file path
+ *
+ * @todo Try retrive public dir from the member function BundleNameBundle::getPublicDir() return value ?
+ * @xxx see https://symfony.com/doc/current/bundles.html#overridding-the-bundle-directory-structure
+ */
+ public function getLocated($file, int $lineno = 0, Source $source = null, \Exception $prev = null) {
+ /*TODO: add a @jquery magic feature ?
+ if ($file == '@jquery') {
+ #header('Content-Type: text/plain');
+ #var_dump($inputs);
+ #exit;
+ return $this->config['jquery'];
+ }*/
+
+ //Check that we have a / separator between bundle name and path
+ if (($pos = strpos($file, '/')) === false) {
+ throw new Error(sprintf('Invalid path "%s"', $file), $token->getLine(), $stream->getSourceContext());