|
Code delimeters
Development
|
|
|||
|
|
Hey everyone, There has been a lack of updates on PHP-Sugar lately. The upside is, this is because I've been quite busy actually using PHP-Sugar in several very large projects. I've learned a lot of things that work very well with Sugar, and other things that do not work so well. One problem we ran into several times was the code delimiters, <% and %>. Many HTML editors do not support these so well, including many of the JavaScript editors that are used by various commercial projects. Some have the ability to enable support for tags like those (they as the ASP tags, iirc), but some unfortunately do not. To make sure things Just Work(tm) for everybody in most situations, I've changed the default delimiters to {% and %}. Those characters do not by default require escaping in HTML, so editors tend to just leave them alone. I've also added synonyms for && and ||, since & tends to have the same problem as < and >. The keywords 'and' and 'or' now exists. Most editors also do not escape the ' character (even though they technically should), so that provides an option instead of " for strings. All in all, Sugar code can be used without fear of escapes with just about every HTML editor I know of. If you prefer <% and %> (or any other set of delimiters), then fear not! Sugar's delimiters are configurable using Sugar::setDelimiters(). To get the old behavior back, for example, try: $sugar = new Sugar(); $sugar->setDelimiters('<%', '%>'); |
||