Source_file_comments in the CMS

Silverstripe Version: 4.2.0

Question:

Hi there, I’m trying to enable source_file_comments, but only in the front end of the site. Is there a way to make sure that source comments do not appear inside the CMS?

I’ve set it up like so:

SilverStripe\View\SSViewer:
  source_file_comments: true

Is there something I’m missing, or are source comments on for every template if enabled?

It’s a global setting. You should be able to enable it dynamically though with

SilverStripe\View\SSViewer::config()->set('source_file_comments', true);

Perhaps you could put that in the init() method of your PageController.php?

public function init()
{
    parent::init();
    if (SilverStripe\Control\Director::isDev()) {
        SilverStripe\View\SSViewer::config()->set('source_file_comments', true);
    }
}

Thanks @JonoM !

:raised_hand_with_fingers_splayed: :mage:

A thing of beauty!

1 Like