Skip to content

Commit c16665c

Browse files
committed
cleanup
1 parent 97ab66a commit c16665c

File tree

5 files changed

+91
-27
lines changed

5 files changed

+91
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ It's perfect for SaaS, web apps, mobile apps, scripts and anywhere you have to s
4040
Use go get:
4141

4242
```bash
43-
go get github.com/templateless/templateless-go
43+
go get github.com/templateless/templateless-go@v0.1.0-alpha.1
4444
```
4545

4646
Then import the package into your own code:

content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (c *Content) Header(header Collection) *Content {
4141
return c
4242
}
4343

44-
func (c *Content) SetFooter(footer Collection) *Content {
44+
func (c *Content) Footer(footer Collection) *Content {
4545
c.Footer_ = footer.Components
4646
return c
4747
}

examples/confirm_email/main.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"os"
6+
7+
"github.com/templateless/templateless-go"
8+
"github.com/templateless/templateless-go/components"
9+
)
10+
11+
func main() {
12+
apiKey := os.Getenv("TEMPLATELESS_API_KEY")
13+
if apiKey == "" {
14+
log.Println("Set TEMPLATELESS_API_KEY to your Templateless API key")
15+
return
16+
}
17+
18+
emailAddress := os.Getenv("TEMPLATELESS_EMAIL_ADDRESS")
19+
if emailAddress == "" {
20+
log.Println("Set TEMPLATELESS_EMAIL_ADDRESS to your own email address")
21+
return
22+
}
23+
24+
header, _ := templateless.NewHeader().
25+
Text("# ExampleApp").
26+
Build()
27+
28+
footer, _ := templateless.NewFooter().
29+
Socials([]components.SocialItem{
30+
*components.NewSocialItem(components.Twitter, "Username"),
31+
*components.NewSocialItem(components.GitHub, "Username"),
32+
}).
33+
Link("Unsubscribe", "https://example.com/unsubscribe?id=123").
34+
Build()
35+
36+
content, _ := templateless.NewContent().
37+
Header(*header).
38+
Text("Hello world").
39+
Footer(*footer).
40+
Build()
41+
42+
email, _ := templateless.NewEmail().
43+
To(*templateless.NewEmailAddress(emailAddress)).
44+
Subject("Confirm your email").
45+
Content(*content).
46+
Build()
47+
48+
result, _ := templateless.NewTemplateless(apiKey).
49+
Send(*email)
50+
51+
log.Println(result)
52+
}

examples/simple.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/simple/main.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"os"
6+
7+
"github.com/templateless/templateless-go"
8+
)
9+
10+
func main() {
11+
apiKey := os.Getenv("TEMPLATELESS_API_KEY")
12+
if apiKey == "" {
13+
log.Println("Set TEMPLATELESS_API_KEY to your Templateless API key")
14+
return
15+
}
16+
17+
emailAddress := os.Getenv("TEMPLATELESS_EMAIL_ADDRESS")
18+
if emailAddress == "" {
19+
log.Println("Set TEMPLATELESS_EMAIL_ADDRESS to your own email address")
20+
return
21+
}
22+
23+
content, _ := templateless.NewContent().
24+
Text("Hello world").
25+
Build()
26+
27+
email, _ := templateless.NewEmail().
28+
To(*templateless.NewEmailAddress(emailAddress)).
29+
Subject("Hello 👋").
30+
Content(*content).
31+
Build()
32+
33+
result, _ := templateless.NewTemplateless(apiKey).
34+
Send(*email)
35+
36+
log.Println(result)
37+
}

0 commit comments

Comments
 (0)