I've done a bit of work over the past week to add negation to the template engine, but after a discussion with Sam, won't commit any new code to the existing SSViewer. We prefer the approach of developing a separate scanner/parser generated from a grammar specification (see PEAR's PHP_LexerGenerator).
However, this work prompted a bit of discussion surrounding the syntactic form that negation should take in template blocks, and I'd be very interested in hearing more opinions about a good direction to head in...
vs stealing 'unless' from Perl:
<% unless Variable %>
The !Var syntax is natural to most programmers used to Algol style languages, but it isn't the most declarative style for a template language - I prefer 'unless' simply because having such a specific construct for negation solves the most common use case of switching a block on or off by checking a single value (rather than the result of an expression, which is a less common use case).
<% Variable != Value %> introduces the use of the ! sigil for negation, but in this case, != is an operator in an infix expression with left and right operands.
!Variable is syntactic sugar for an boolean operand evaluated under 'if' (eq to Variable != true or Variable == false), wheras 'unless' is a statement itself, symmetric to 'if' (though there doesn't seem to be a practical difference).
I prefer to see the template language leading from declarative natural language as closely as possible, hence my +1 vote for 'unless'.
SilverStripe is already doing quite well in this regard, especially in comparison to Smarty et al, and even Django. After doing more with the SS syntax for a couple weeks, I definitely much prefer the way that 'control' scopes work, as opposed to annoying looping constructs in other template languages. In the same way, I feel that 'unless' works really well here, but I appreciate it may not be to everyone's taste.
The reason why I like it is that although it's not as concise as the operand, using the specific keyword statement fits in better with the general declarative look of HTML, a little easier on the eye, and doesn't feel like jumping into programming or mathematical expressions in the template.
There's no reason why we couldn't support both, except for the slippery slope problem of course, in that taking the philosophy of Perl (TIMTOWTDI) is probably NOT the right way to approach designing a template syntax ;)
There's also no reason why we can't move towards a pluggable syntax, once we have swapped out the regex cascade in SSViewer with a more modular lexical analyzer.
This would mean that as long as the right events were emitted from the lexer, it would be possible to have a Smarty or Django style syntax compile to the common Sapphire template infrastructure... I see this as a "nice to have", and absolutely the furtherest thing from being a priority, but I think it would keep a few people happy, and contribute to encouraging more experienced developers to pick up SilverStripe as a framework.
I personally like the idea of keeping the SS syntax concise and to the point. Smarty is a total kitchen sink situation, wheras the control blocks in SS encourage a more declarative and HTML friendly way of thinking, which is the very point of having an HTML embedded template syntax in the first place.
When you reach the point of having a turing complete template language, you know you've failed.