You can contribute to Templater by developing a new internal function / variable.
The process to develop a new one is really easy.
Keep in mind that only pertinent submissions will be accepted, don't submit a very specific internal variable / function that you'll be the only one using.
Internal variables / functions are sorted by modules. Each module has a dedicated folder under src/InternalTemplates.
Let's take the date module as an example.
It contains an InternalModuleDate file where all our internal date's related variables and functions are defined and registered:
Every module extends the InternalModule abstract class, which means they contain the following attributes and methods:
this.appattribute: the obsidian API
this.fileattribute: The destination file where the template will be inserted.
this.pluginattribute: The Templater plugin object.
this.static_templatesattribute: A map containing all (name; variable/function) that are static. A static variable / function means that it doesn't depend on the file when executed. These type of variables / functions won't be updated each time we insert a new template, to save some overhead.
this.dynamic_templatesattribute: Same as
static_templatesexcept that it contains variables / functions dependent on the file when executed.
this.createStaticTemplates()method: Registers all static internal variable / function for that module.
this.updateTemplates()method: Registers every dynamic internal variable / function for that module.
You can use these attributes in your new internal variable / function if you need them.
Here are the different steps you need to follow, in order to register a new internal variable / function in a module.
1st step: Create a method inside the module called
generate_<internal_variable_or_function_name>() that will generate your internal variable / function, that means it will return either a lambda function (representing the internal function) or directly the internal variable you want to expose.
All generation methods are ordered by alphabetical order based on the internal variable / function name.
Try to give a good, self-explanatory name for your variable / function.
2nd step: Register your internal variable / function in the
dynamic_templates map depending on whether your internal variable / function on the file when executed. The registration happens either in
To register your variable / function, use your
this.generate_<internal_variable_or_function_name>() method you defined earlier:
Internal variable / function registrations are also ordered by alphabetical order based on the variable / function name.
3rd step: Add your internal variable / function documentation to Templater's documentation.
And you are done ! Thanks for contributing to Templater !
Now, just submit a pull request on Github, I'll try to be as reactive as possible.