File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 "errors"
55 "fmt"
66 "html/template"
7+ "io"
78 "log"
9+ "net/http"
810 "net/textproto"
911 "strings"
1012 "sync"
@@ -371,6 +373,20 @@ func (m *Manager) TemplateFuncs(c *models.Campaign) template.FuncMap {
371373 "RootURL" : func () string {
372374 return m .cfg .RootURL
373375 },
376+ "externalHTML" : func (url string ) (template.HTML , error ) {
377+ resp , err := http .Get (url )
378+ if err != nil {
379+ return "" , err
380+ }
381+ defer resp .Body .Close ()
382+
383+ body , err := io .ReadAll (resp .Body )
384+ if err != nil {
385+ return "" , err
386+ }
387+
388+ return template .HTML (body ), nil
389+ },
374390 }
375391
376392 maps .Copy (f , m .tplFuncs )
@@ -618,6 +634,20 @@ func (m *Manager) makeGnericFuncMap() template.FuncMap {
618634 "Safe" : func (safeHTML string ) template.HTML {
619635 return template .HTML (safeHTML )
620636 },
637+ "externalHTML" : func (url string ) (template.HTML , error ) {
638+ resp , err := http .Get (url )
639+ if err != nil {
640+ return "" , err
641+ }
642+ defer resp .Body .Close ()
643+
644+ body , err := io .ReadAll (resp .Body )
645+ if err != nil {
646+ return "" , err
647+ }
648+
649+ return template .HTML (body ), nil
650+ },
621651 }
622652
623653 // Copy spring functions.
You can’t perform that action at this time.
0 commit comments