public function validate($data) {
        if (empty($data)) {
            return true;
        }

        $scss = new core_scss();
        try {
            $scss->compile($data);
        } catch (Leafo\ScssPhp\Exception\ParserException $e) {
            return get_string('scssinvalid', 'admin', $e->getMessage());
        } catch (Leafo\ScssPhp\Exception\CompilerException $e) {
            // Silently ignore this - it could be a scss variable defined from somewhere
            // else which we are not examining here.
            return true;
        }

        return true;
    }
public function validate($data) {
        if (empty($data)) {
            return true;
        }

        $scss = new core_scss();
        try {
            $scss->compile($data);
        } catch (Leafo\ScssPhp\Exception\ParserException $e) {
            return get_string('scssinvalid', 'admin', $e->getMessage());
        } catch (Leafo\ScssPhp\Exception\CompilerException $e) {
            // Silently ignore this - it could be a scss variable defined from somewhere
            // else which we are not examining here.
            return true;
        }

        return true;
    }
public function validate ( $ data ) { if ( empty ( $ data ) ) { return true ; } $ scss = new core_scss ( ) ; try { $ scss -> compile ( $ data ) ; } catch ( Leafo \ ScssPhp \ Exception \ ParserException $ e ) { return get_string ( 'scssinvalid' , 'admin' , $ e -> getMessage ( ) ) ; } catch ( Leafo \ ScssPhp \ Exception \ CompilerException $ e ) { // Silently ignore this - it could be a scss variable defined from somewhere // else which we are not examining here. return true ; } return true ; }
Validate the contents of the SCSS to ensure its parsable. Does not
attempt to detect undefined scss variables.

@param string $data The scss code from text field.
@return mixed bool true for success or string:error on failure.
Validate the contents of the SCSS to ensure its parsable . Does not attempt to detect undefined scss variables .