Welcome Guest, Not a member yet? Register   Sign In
Parser Plugins - Open & Closing Tag Usage
#1

Hi,
I am trying to create some custom parser plugins within a module I am working on.
I have single tag plugins with or without parameters functioning fine.
However, when I try to use opening and closing plugin tags the closing tags line is rendered in the output. I am also unsure how to access the content within the tags from withing my plugin function.
The documentation for parser plugins is fairly sparce. Any examples of an open and closing tag plugin functions would be much appreciated.
Reply
#2

It would help if you show your code
Reply
#3

I am loading plugins using my modules Config\Registrar.php:

Code:
class Registrar
{
    public static function View(): array
    {
        return [
            'plugins' => [
                'include' => '\Modules\CMS\Libraries\ParserPlugins::include',
                'test' => '\Modules\CMS\Libraries\ParserPlugins::test',
            ],
        ];
    }
}
My ParserPlugins class contains the following:

Code:
class ParserPlugins
{
    public static function include(array $params = [])
    {
        $parser = \Config\Services::parser();
        return $parser->render(...$params);
    }

    public static function test(array $params = [])
    {       
        return 'Test';
    }
}

I try to use opening and closing plugin tags like so:

Code:
{+ test +} inner content {+ /test +}

However, the only params I can access are those I add to the opening tag. I am unsure how to access the content between the tags.

The closing tag is also still be rendered on the page as
Code:
{+ /test +}
.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB