This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

richie1803
richie1803

I am considering installing TwigBridge into October so i can access Laravel features such as Form, Auth ect. but i am not sure if it is "bad practice" accessing, classes such as Auth from the Twig template? is it better to keep the templates sterile and do everything in the controller?

Any views on this?

daftspunky
daftspunky

I think you'll find most of them are already included, otherwise you can add them easily yourself without using TwigBridge.

        /*
         * Register markup tags
         */
        MarkupManager::instance()->registerCallback(function($manager){
            $manager->registerFunctions([
                // Functions
                'post'           => 'post',
                'link_to'        => 'link_to',
                'link_to_asset'  => 'link_to_asset',
                'link_to_route'  => 'link_to_route',
                'link_to_action' => 'link_to_action',
                'asset'          => 'asset',
                'action'         => 'action',
                'url'            => 'url',
                'route'          => 'route',
                'secure_url'     => 'secure_url',
                'secure_asset'   => 'secure_asset',

                // Classes
                'str_*'          => ['Str', '*'],
                'url_*'          => ['URL', '*'],
                'html_*'         => ['HTML', '*'],
                'form_*'         => ['Form', '*'],
                'form_macro'     => ['Form', '__call'],
            ]);

            $manager->registerFilters([
                // Classes
                'slug'           => ['Str', 'slug'],
                'plural'         => ['Str', 'plural'],
                'singular'       => ['Str', 'singular'],
                'finish'         => ['Str', 'finish'],
                'snake'          => ['Str', 'snake'],
                'camel'          => ['Str', 'camel'],
                'studly'         => ['Str', 'studly'],
                'md'             => ['October\Rain\Support\Markdown', 'parse'],
            ]);
        });

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.