This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I would like to implement some Twig container tags similar to {% put %}/{% endput %} to manage the modular nature of my (mostly static) content.  I can steal code from the implementations of {% put %}/{% endput %} to implement the containers.  However, I need to know how to hook them into October.  Any help would be most appreciated.  Thanks in advance...
-- sw
You can create a plugin to extend twig. Thats what I did at least. Not sure if it is the best way.
https://octobercms.com/docs/plugin/registration#extending-twig
My Plugin.php example:
<?php 
namespace JonathanMaloy\Twig;
class Plugin extends \System\Classes\PluginBase
{
    public function pluginDetails()
    {
        return [
            'name' => 'Twig Plugin',
            'description' => 'Twig addons',
            'author' => 'Jonathan Maloy'
        ];
    }
    public function registerMarkupTags()
    {
        return [
            'filters' => [
                'truncate' => function($value, $length = 30, $separator = '...') {
                    if (strlen($value) > $length) {
                        return rtrim(substr($value, 0, $length)) . $separator;
                    }
                    return $value;
                },
                'serialize' => function($value) {
                    return http_build_query($value,'','', PHP_QUERY_RFC3986);
                }
            ]
        ];
    }
}Last updated
Jonathan --
Thanks for the quick reply...  I know that...I've written some of these already.  In the implementation of {% put %}/{% endput %}, there's a parser class and a node class.  Neither of them have a registerMarkup() method.  I think registerMarkup() is for simple functions.  What I'm after is how to register methods to process a block...again like {% put %}/{% endput %}.
-- sw
1-3 of 3