xeoncross / PHP-Template

Simple PHP template inheritance and view management class using pure PHP
28 stars 4 forks source link

Minify html #7

Closed kamov closed 7 years ago

kamov commented 7 years ago

Hi, I have create a function minify_html(), and then as explained here: http://stackoverflow.com/questions/6225351/how-to-minify-php-page-html-output I have added this on ob_start as below:

ob_start('minify_html');

As you know is correct to add on your template on all three functions, this: or just on load() ?

    /**
     * Load the given template
     *
     * @param string $__f file name
     * @return string
     */
    public function load($__f)
    {
        ob_start('minify_html');
        extract((array) $this);
        require self::$path . $__f . '.php';
        return ob_get_clean();
    }
    /**
     * Extend a parent template
     *
     * @param string $__f name of template
     */
    public function extend($__f)
    {
        ob_end_clean(); // Ignore this child class and load the parent!
        ob_start('minify_html');
        print $this->load($__f);
    }
    /**
     * Start a new block
     */
    public function start()
    {
        ob_start('minify_html');
    }

Thanks!

xeoncross commented 7 years ago

You only need to call the function in load() since the other two are inside the load() function call.

kamov commented 7 years ago

THanks!