-
Notifications
You must be signed in to change notification settings - Fork 0
Templates
Shaye Garg edited this page Oct 3, 2021
·
8 revisions
Templates and behavior expressions are what lets you actually do stuff with behave.
A template is essentially a function that can be used inside the behavior element (or inside other templates).
The template can then generate behavior expressions according to the arguments it receives.
behave has many behavior expressions:
A template definition has the form:
template <ident>(<ident>: <type>, <ident>: <type> = <expr>) {
<anything_that_can_go_in_behavior>
}
// This would be:
template MyTemplate(node: str, id: num = 0) {
// Stuff
}anything_that_can_go_in_behavior:
- Any behavior expression
- An expression that either evaluates into a behavior expressions or
none(likeifs andswitches. - Variable declarations.
Templates can also have default arguments.