How to handle year and date in template? #254
-
Hi, Some bibtex entry only have date field others have year filed, I set a template to escape "year" as a org headline, but it will be empty if the bibtex entry only have "date" field. Is there a field keyword that can handle both conditions:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, no, there is no such keyword. You are welcome to submit a feature request. It will take some time though because I'll be quite busy until the end of next week. You can achieve what you want with LISP expressions in your template. Read the documentation of (defun my-orb-year-or-date (keyword1 keyword2)
(if (string-empty-p keyword1)
keyword2
keyword1)) Adjust it to your needs to handle the conversion of date to year. And then in the templates: (setq org-roam-capture-templates
'(("r" "reference" plain ""
:target
(file+head "${citekey}.org" "#+TITLE: ${title}
%(my-orb-year-or-date \"%^{year}\" \"%^{date}\")")))) |
Beta Was this translation helpful? Give feedback.
Hi,
no, there is no such keyword. You are welcome to submit a feature request. It will take some time though because I'll be quite busy until the end of next week.
You can achieve what you want with LISP expressions in your template. Read the documentation of
org-capture-templates
.You can have a function, for example, which takes both the keywords and then returns a non-empty result if one of the fields is non-empty. It'd look something like this:
Adjust it to your needs to handle the conversion of date to year. And then in the templates: