Re: [RFC] New operator for context-dependent escaping

From: Date: Sun, 17 Jul 2016 10:43:55 +0000
Subject: Re: [RFC] New operator for context-dependent escaping
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-94528@lists.php.net to get a copy of this message
2016-07-17 12:35 GMT+02:00 Michael Vostrikov <michael.vostrikov@gmail.com>: > > > > Multiple arguments would make the syntax even cleaner: > > <?* $str, 'js', 'html' ?> > > > > I thought about it. Multiple arguments do not allow runtime modification > (and make the parser more complex). > Something like this: > <?php > $context = []; > if ($field->name == 'url') $context[] = 'url'; > $context[] = 'html'; > ?> > <div data-my-attr="<?* $field->value, implode('|', $context) > ?>"></div> > Context should be defined where the variable is printed. Otherwise you move the variable from HTML text to an attribute or add it somewhere else and the context doesn't match anymore. Regards, Niklas

« previous php.internals (#94528) next »