private function isCacheUpToDate(&$path, $input = null)
    {
        if (!$input) {
            $compiler = $this->getRenderer()->getCompiler();
            $input = $compiler->resolve($path);
            $path = $this->getCachePath(
                ($this->getOption('keep_base_name') ? basename($path) : '').
                $this->hashPrint($input)
            );

            // If up_to_date_check never refresh the cache
            if (!$this->getOption('up_to_date_check')) {
                return true;
            }

            // If there is no cache file, create it
            if (!file_exists($path)) {
                return false;
            }

            // Else check the main input path and all imported paths in the template
            return !$this->hasExpiredImport($input, $path);
        }

        $path = $this->getCachePath($this->hashPrint($input));

        // Do not re-parse file if the same hash exists
        return file_exists($path);
    }