Closed MysteryBlokHed closed 3 years ago
Right now you need to have a space between the macro call and its arguments (eg. ?macro_name ("argument")
) because of how I'm detecting macro calls, but that probably shouldn't be too hard to fix.
For some reason, it looks like there's a bug right now related to calling two macros in the same file. Even two calls in different functions don't work. This is probably caused if the variables used for calling macros not being fully reset at the end of a call.
Macro calls should now be able to accept any formatting. For example, all of the following calls would work:
!def my_macro($arg1)
say $arg1
!end
?my_macro("Hello")
?my_macro ("Hello")
?my_macro
("Hello")
?my_macro(
"Hello",
)
The documentation for macros in their current state is done.
When the custom filetypes are added, a new section can be made in the macros docs page (docs/macros.rst
)
I think that instead of adding a new filetype, I'll make files beginning with @
able to define global macros. Using a new filetype probably wouldn't have worked any way, since you're able to change compiled files in the databind.toml
config.
For example, a file named @command_macros.databind
or @functions.databind
would be able to define global macros.
These files will still be able to define functions, but it won't be their main purpose.
The commit's description should say #59, not #58. Luckily it's not super critical.
Closes #59
Adds macros to Databind. Example definition:
As seen above, macros can take a list of comma-separated arguments, each beginning with
$
. When used in the body of the macro, any instances of the argument names are replaced with whatever is passed from a macro call.An example call would look like this:
Which would be replaced with the following: