Added code snippet to documentation to describe handling null values with date filter

This commit is contained in:
cb
2012-03-22 13:12:09 -05:00
parent ab016bd605
commit bf0cc537e3
+7
View File
@@ -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") }}