Skip to content

Commit

Permalink
Clarified usage of FileTemplateLoader and setBase
Browse files Browse the repository at this point in the history
  • Loading branch information
chbloemer committed Dec 27, 2024
1 parent ecdaea4 commit 6d2a020
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,12 @@ config.setSharedVariables(defaults);
By default, pug4j searches for template files in your work directory. By specifying your own `FileTemplateLoader`, you can alter that behavior. You can also implement the `TemplateLoader` interface to create your own.

```java
TemplateLoader loader = new FileTemplateLoader("/templates/", "UTF-8");
TemplateLoader loader = new FileTemplateLoader("/templates/", "UTF-8"); //Defines the path under which all templates are found. You can't include templates from parent directory "/"
loader.setBase("my-maintemplates/"); //the folder where all files starting with "/" are found. This where your main templates are.
config.setTemplateLoader(loader);
```
* '/index' points to '/templates/my-maintemplates/index.pug'
* 'index' points to '/templates/index.pug'

There is also a `ClasspathTemplateLoader` and `ReaderTemplateLoader`.

Expand Down

0 comments on commit 6d2a020

Please sign in to comment.