-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Cloudflare treats the "functions" dir as a special directory, so files in this dir will not be deployed. This is now fixed by changing that directory to "funcs" instead. See cloudflare/workers-sdk#2240
- Loading branch information
1 parent
a1d2562
commit f46a773
Showing
29 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
order: 10 | ||
path: | ||
--- | ||
|
||
# Functions | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
order: 1011 | ||
title: module.Call | ||
--- | ||
|
||
<!-- Generated by tools/docgen. DO NOT EDIT. --> | ||
|
||
# module.Call | ||
|
||
Call executes a template function by name with the provided arguments. | ||
The function must have been exported by the module that provides it | ||
through the [Export] function. | ||
|
||
Attempting to call a function that does not exist will return an error | ||
outside of the first pass where it will return `nil` instead. | ||
|
||
The template that is called must return a value using the `return` | ||
template function, which is only available in this context. | ||
|
||
In addition, all of the file, stencil and other functions are in the | ||
context of the parent template, not the template being called. | ||
|
||
`.` in a template function acts the same way as it does for [TplStencil.ApplyTemplate](#TplStencil.ApplyTemplate) (`stencil.ApplyTemplate`). Meaning, it points to [Values](#Values). The caller passed data is accessible on `.Data`. | ||
|
||
Example: | ||
|
||
```go | ||
// module-a | ||
{{- define "HelloWorld" }} | ||
{{- return (printf "Hello, %s!" .Data) }} | ||
{{- end }} | ||
{{ module.Export "HelloWorld" }} | ||
|
||
// module-b | ||
{{ module.Call "module-b.HelloWorld" "Jared" }} | ||
// Output: Hello, Jared | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
order: 1012 | ||
title: module.Export | ||
--- | ||
|
||
<!-- Generated by tools/docgen. DO NOT EDIT. --> | ||
|
||
# module.Export | ||
|
||
Export registers a function to allow it to be called by other templates. | ||
|
||
This is only able to be called in library templates and the function's | ||
name must start with a capital letter. Function names are also only | ||
eligible to be exported once, if a function is exported twice the second | ||
call will be a runtime error. | ||
|
||
Example: | ||
|
||
```go | ||
{{- define "HelloWorld" }} | ||
{{- return (printf "Hello, %s!" .Data) }} | ||
{{- end }} | ||
|
||
{{ module.Export "HelloWorld" }} | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters