From: cb Date: Thu, 22 Mar 2012 18:12:09 +0000 (-0500) Subject: Added code snippet to documentation to describe handling null values with date filter X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=bf0cc537e3eaf61449fe27826b51a0ff2767c694;p=konrad%2Ftwig.git Added code snippet to documentation to describe handling null values with date filter --- diff --git a/doc/filters/date.rst b/doc/filters/date.rst index b6a29e4..9833f03 100644 --- a/doc/filters/date.rst +++ b/doc/filters/date.rst @@ -56,3 +56,10 @@ The default timezone can also be set globally by calling ``setTimezone()``: .. _`date`: http://www.php.net/date .. _`DateTime`: http://www.php.net/DateTime .. _`DateInterval`: http://www.php.net/DateInterval + +If the value passed to the ``date`` filter is null, it will return the current date by default. +If an empty string is desired instead of the current date, use a ternary operator: + +.. code-block:: jinja + + {{ post.published_at is empty ? "" : post.published_at|date("m/d/Y") }}