From 214f2f08e40aed660d2dc76c809ba035656e827f Mon Sep 17 00:00:00 2001 From: the-solipsist Date: Wed, 26 Aug 2020 16:04:14 +0530 Subject: Make the setting-the-date example conditional This makes the example a bit more realistic/valuable by checking if the metadata value "date" is already present, before changing the value. --- doc/lua-filters.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 1862700c9..1cdad7391 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -362,12 +362,14 @@ end ## Setting the date in the metadata This filter sets the date in the document's metadata to the -current date: +current date, if a date isn't already set: ``` lua function Meta(m) - m.date = os.date("%B %e, %Y") - return m + if m.date == nil then + m.date = os.date("%B %e, %Y") + return m + end end ``` -- cgit v1.2.3