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.
This commit is contained in:
the-solipsist 2020-08-26 16:04:14 +05:30 committed by Albert Krewinkel
parent 93e3d463fd
commit 214f2f08e4

View file

@ -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
```