From bf0cc537e3eaf61449fe27826b51a0ff2767c694 Mon Sep 17 00:00:00 2001 From: cb Date: Thu, 22 Mar 2012 13:12:09 -0500 Subject: [PATCH] Added code snippet to documentation to describe handling null values with date filter --- doc/filters/date.rst | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) 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") }} -- 1.7.2.5