Skip to content

Commit

Permalink
steal docs
Browse files Browse the repository at this point in the history
  • Loading branch information
erdos committed Jul 29, 2024
1 parent 867dcaa commit 6c34f0f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ Expects one number argument containing a list with numbers. Sums up the numbers

## Custom functions

You can register custom implementations of `io.github.erdos.stencil.functions.Function` or the `stencil.functions/call-fn` multimethod.
You can register custom implementations of `io.github.erdos.stencil.functions.Function` or the `stencil.functions/call-fn` multimethod.
If you implement the `call-fn` multimethod, the namespace containing these implementations should be loaded before rendering a document.
(Keep in mind, that `call-fn` implementations always have priority over `io.github.erdos.stencil.functions.Function` implementations)

Clojure example:

Expand Down Expand Up @@ -271,3 +273,10 @@ public class FirstFuncion implements Function {

API.render(preparedTemplate, fragments, data, Arrays.asList(new FirstFunction()));
```


### Automatic registration of custom functions

Stencil uses the JVM's [ServiceLoader](https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html) facility to load function provider implementations.
If you want to register your custom functions automatically, implement the `io.github.erdos.stencil.functions.FunctionsProvider` interface,
and add these implementations to your extension library's `META-INF/services/io.github.erdos.stencil.functions.FunctionsProvider` file.

0 comments on commit 6c34f0f

Please sign in to comment.