src/endobox/BoxFactory.php
public function create(string $template) : Box
    {
        foreach ($this->paths as &$path) {
            // full path to template file without extension
            $file = \rtrim($path, '/') . '/' . \trim($template, '/');

            if (\file_exists($t = $file . '.php')) {
                return (new Box(
                        new Template($t),
                        new EvalRendererDecorator(
                            new NullRenderer())))
                            ->assign([
                                'markdown' => function($md) {
                                    return new Box(
                                        new Atom($md),
                                        new MarkdownRendererDecorator(
                                            new NullRenderer(), $this->parsedown));
                                }
                            ]);
            }

            if (\file_exists($t = $file . '.md.php')) {
                return (new Box(
                        new Template($t),
                        new MarkdownRendererDecorator(
                            new EvalRendererDecorator(
                                new NullRenderer()), $this->parsedown)))
                                ->assign([
                                    'markdown' => function($md) {
                                        return new Box(
                                            new Atom($md),
                                            new MarkdownRendererDecorator(
                                                new NullRenderer(), $this->parsedown));
                                    }
                                ]);
            }

            if (\file_exists($t = $file . '.md')) {
                return new Box(
                        new Template($t),
                        new MarkdownRendererDecorator(
                            new NullRenderer(), $this->parsedown));
            }

            if (\file_exists($t = $file . '.html')) {
                return new Box(
                        new Template($t),
                        new NullRenderer());
            }
        }

        throw new \RuntimeException(\sprintf('Template "%s" not found.', $template));
    }
public function create(string $template) : Box
    {
        foreach ($this->paths as &$path) {
            // full path to template file without extension
            $file = \rtrim($path, '/') . '/' . \trim($template, '/');

            if (\file_exists($t = $file . '.php')) {
                return (new Box(
                        new Template($t),
                        new EvalRendererDecorator(
                            new NullRenderer())))
                            ->assign([
                                'markdown' => function($md) {
                                    return new Box(
                                        new Atom($md),
                                        new MarkdownRendererDecorator(
                                            new NullRenderer(), $this->parsedown));
                                }
                            ]);
            }

            if (\file_exists($t = $file . '.md.php')) {
                return (new Box(
                        new Template($t),
                        new MarkdownRendererDecorator(
                            new EvalRendererDecorator(
                                new NullRenderer()), $this->parsedown)))
                                ->assign([
                                    'markdown' => function($md) {
                                        return new Box(
                                            new Atom($md),
                                            new MarkdownRendererDecorator(
                                                new NullRenderer(), $this->parsedown));
                                    }
                                ]);
            }

            if (\file_exists($t = $file . '.md')) {
                return new Box(
                        new Template($t),
                        new MarkdownRendererDecorator(
                            new NullRenderer(), $this->parsedown));
            }

            if (\file_exists($t = $file . '.html')) {
                return new Box(
                        new Template($t),
                        new NullRenderer());
            }
        }

        throw new \RuntimeException(\sprintf('Template "%s" not found.', $template));
    }
public function create ( string $ template ) : Box { foreach ( $ this -> paths as & $ path ) { // full path to template file without extension $ file = \ rtrim ( $ path , '/' ) . '/' . \ trim ( $ template , '/' ) ; if ( \ file_exists ( $ t = $ file . '.php' ) ) { return ( new Box ( new Template ( $ t ) , new EvalRendererDecorator ( new NullRenderer ( ) ) ) ) -> assign ( [ 'markdown' => function ( $ md ) { return new Box ( new Atom ( $ md ) , new MarkdownRendererDecorator ( new NullRenderer ( ) , $ this -> parsedown ) ) ; } ] ) ; } if ( \ file_exists ( $ t = $ file . '.md.php' ) ) { return ( new Box ( new Template ( $ t ) , new MarkdownRendererDecorator ( new EvalRendererDecorator ( new NullRenderer ( ) ) , $ this -> parsedown ) ) ) -> assign ( [ 'markdown' => function ( $ md ) { return new Box ( new Atom ( $ md ) , new MarkdownRendererDecorator ( new NullRenderer ( ) , $ this -> parsedown ) ) ; } ] ) ; } if ( \ file_exists ( $ t = $ file . '.md' ) ) { return new Box ( new Template ( $ t ) , new MarkdownRendererDecorator ( new NullRenderer ( ) , $ this -> parsedown ) ) ; } if ( \ file_exists ( $ t = $ file . '.html' ) ) { return new Box ( new Template ( $ t ) , new NullRenderer ( ) ) ; } } throw new \ RuntimeException ( \ sprintf ( 'Template "%s" not found.' , $ template ) ) ; }
Create a Box based on the given template and return it.
Create a Box based on the given template and return it .