template tal - PHPTAL: graceful treatment of undefined variables -


If I use a variable which is not scoped, then PHPTAL throws an exception to creating PHPTAL Any way comes back to the pretty defaults, for example, evaluating false in the Boolean context, to clear the string context, etc.?

You can add " | nothing " to the expression in the Tables or < Code> isset () in php: expression can be used.

  & lt; P tal: attributes = "class php: isset (class)? Class: NULL" tal: content = "variable | nothing" />  

If you have some large code that depends on a certain variable, then is present: modifier:

  & Lt; Div tal: condition = "exists: variable" & gt; ... & lt; / Div & gt;  

If you want a fake existence of any variable, it can be done, but I do not recommend it (this will hide the typo):

  Class fake all stdClass spanning {function __get ($ var) {return "";} function __isset ($ var) {return true;}} $ p = new PHPTAL (); $ P- & gt; GetContext () - & gt; Set Global (New FakeAll ());  

Comments