diff --git a/docs/Functions.md b/docs/Functions.md index 60df5531..38bb7b75 100644 --- a/docs/Functions.md +++ b/docs/Functions.md @@ -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: @@ -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. \ No newline at end of file