-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic template insertion in daily notes #195
Conversation
…r custom daily template variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @MunsMan, this is great.
Currently, custom variables aren't added to the normal templates yet, but that would be just a three line change.
I think it makes sense to add that in this PR, do you mind?
README.md
Outdated
@@ -323,7 +327,8 @@ For example, with the following configuration | |||
templates = { | |||
subdir = "my-templates-folder", | |||
date_format = "%Y-%m-%d-%a", | |||
time_format = "%H:%M" | |||
time_format = "%H:%M", | |||
custom = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about calling this substitutions
(or something like that)?
custom = {} | |
substitutions = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, substitutions
or variables
would be a better fit.
I will update it to substitutions
for now.
README.md
Outdated
@@ -214,6 +216,8 @@ This is a complete list of all of the options that can be passed to `require("ob | |||
subdir = "templates", | |||
date_format = "%Y-%m-%d-%a", | |||
time_format = "%H:%M", | |||
-- A map for custom variables, the key should be the variable and the value a function | |||
custom = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably omit this here and just use what's in templates
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that are the default options. I would list it there with the empty list, just to make the exists of the option clear. Likewise, I will update it to substitutions
.
Please correct me if I'm wrong. I thought the default config is from line 135 to 258 and on line 324 to 333 are an example. I will add a proper substitutions
example.
I just added the substitution support for the default template as well. Furthermore, I renamed it to If you have anything else, just led me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @MunsMan!
…tions (epwalsh#195) * Option for automatic template insertion in daily notes and support for custom daily template variables * README rename custom to substituetions and clean up example * rename variable from custom to substitutions and adding substitutions to default template * Apply suggestions from code review --------- Co-authored-by: Pete <[email protected]>
This pull request adds support for automatic template insertion in daily notes.
To enable the feature, just add the full template name to the daily note config:
Furthermore, I added support for custom template variables.
It is done by the
util.substitute_template_variables
with tasks the currently available variables and a map of new variables.There the variables are a name, function pair. The executed function should return the inserted value.
An Example is in the README.
Currently, custom variables aren't added to the normal templates yet, but that would be just a three line change.
Please give me your thought on this feature.
This should close #163