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.
commit214f2f08e40aed660d2dc76c809ba035656e827f
authorthe-solipsist <the.solipsist@gmail.com>
dateWed 26 Aug 2020, 16:04 (6 years ago)
parent93e3d46
doc/lua-filters.md+5−3
@@ -362,12 +362,14 @@ end
362362## Setting the date in the metadata
363363
364364This filter sets the date in the document's metadata to the
365−current date:
365+current date, if a date isn't already set:
366366
367367``` lua
368368function Meta(m)
369− m.date = os.date("%B %e, %Y")
370− return m
369+ if m.date == nil then
370+ m.date = os.date("%B %e, %Y")
371+ return m
372+ end
371373end
372374```
373375