Skip to content

Commit

Permalink
Add basename function to sgml FuncMap (#1104)
Browse files Browse the repository at this point in the history
This function is necessary to allow custom backends to only use the
basename of an image in cases where images are stored as attachments.

```
blockImageTmpl = `<image ><attachment filename="{{ basename .Src }}" /></image>`
```

Co-authored-by: David Gamba <[email protected]>
  • Loading branch information
davidgamba-au and DavidGamba authored Mar 9, 2023
1 parent f760dcb commit 529d0d0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/renderer/sgml/sgml.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sgml
import (
"fmt"
"io"
"path/filepath"
"strings"
texttemplate "text/template"

Expand All @@ -19,6 +20,7 @@ func Render(doc *types.Document, config *configuration.Configuration, output io.
templates: tmpls,
// Establish some default function handlers.
functions: texttemplate.FuncMap{
"basename": filepath.Base,
"escape": escapeString,
"halign": halign,
"lastInStrings": lastInStrings,
Expand Down

0 comments on commit 529d0d0

Please sign in to comment.