summary refs log tree commit diff stats
path: root/lib/templates
diff options
context:
space:
mode:
Diffstat (limited to 'lib/templates')
-rw-r--r--lib/templates/template.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/templates/template.go b/lib/templates/template.go
index 21f7b35..8a345d9 100644
--- a/lib/templates/template.go
+++ b/lib/templates/template.go
@@ -10,6 +10,7 @@ import (
 	"text/template"
 	"time"
 
+	"git.sr.ht/~sircmpwn/aerc/models"
 	"github.com/mitchellh/go-homedir"
 )
 
@@ -28,20 +29,23 @@ type TemplateData struct {
 
 func TestTemplateData() TemplateData {
 	defaults := map[string]string{
-		"To":           "John Doe <john@example.com>",
-		"Cc":           "Josh Doe <josh@example.com>",
-		"From":         "Jane Smith <jane@example.com>",
-		"Subject":      "This is only a test",
-		"OriginalText": "This is only a test text",
-		"OriginalFrom": "John Doe <john@example.com>",
-		"OriginalDate": time.Now().Format("Mon Jan 2, 2006 at 3:04 PM"),
+		"To":      "John Doe <john@example.com>",
+		"Cc":      "Josh Doe <josh@example.com>",
+		"From":    "Jane Smith <jane@example.com>",
+		"Subject": "This is only a test",
 	}
 
-	return ParseTemplateData(defaults)
+	original := models.OriginalMail{
+		Date: time.Now().Format("Mon Jan 2, 2006 at 3:04 PM"),
+		From: "John Doe <john@example.com>",
+		Text: "This is only a test text",
+	}
+
+	return ParseTemplateData(defaults, original)
 }
 
-func ParseTemplateData(defaults map[string]string) TemplateData {
-	originalDate, _ := time.Parse("Mon Jan 2, 2006 at 3:04 PM", defaults["OriginalDate"])
+func ParseTemplateData(defaults map[string]string, original models.OriginalMail) TemplateData {
+	originalDate, _ := time.Parse("Mon Jan 2, 2006 at 3:04 PM", original.Date)
 	td := TemplateData{
 		To:           parseAddressList(defaults["To"]),
 		Cc:           parseAddressList(defaults["Cc"]),
@@ -49,8 +53,8 @@ func ParseTemplateData(defaults map[string]string) TemplateData {
 		From:         parseAddressList(defaults["From"]),
 		Date:         time.Now(),
 		Subject:      defaults["Subject"],
-		OriginalText: defaults["Original"],
-		OriginalFrom: parseAddressList(defaults["OriginalFrom"]),
+		OriginalText: original.Text,
+		OriginalFrom: parseAddressList(original.From),
 		OriginalDate: originalDate,
 	}
 	return td
lowercase' href='/akkartik/mu/commit/examples/ex3.subx?h=hlt&id=333525360b22f3d3ea31db46a4d2f1b4edbfebdb'>33352536 ^
97a9bd17 ^
f3901d90 ^
1639687b ^
33352536 ^
6030d7e2 ^

33352536 ^
6030d7e2 ^
33352536 ^
6030d7e2 ^

97a9bd17 ^
f3901d90 ^
ecfbbfb5 ^

294a1520 ^
ee9a9237 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
                                                                   
 
         
                                                                   
                             


                  
 
       


                                                                                                                                                 
 
      



                           
 
      
                             
                                                                                                                                                                   

                                   
                                                                                                                                                                      
               
                    

                        
 
      

                                
 
                            
# Add the first 10 numbers, and return the result in the exit code.
#
# To run:
#   $ ./subx translate init.linux examples/ex3.subx -o examples/ex3
#   $ ./subx run examples/ex3
# Expected result:
#   $ echo $?
#   55

== code
#   instruction                     effective address                                                   register    displacement    immediate
# . op          subop               mod             rm32          base        index         scale       r32
# . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes

Entry:
    # result: ebx = 0
    bb/copy-to-ebx  0/imm32
    # counter: ecx = 1
    b9/copy-to-ecx  1/imm32

$loop:
    # if (counter > 10) break
    81          7/subop/compare     3/mod/direct    1/rm32/ecx    .           .             .           .           .               0xa/imm32         # compare ecx
    7f/jump-if-greater  $exit/disp8
    # result += counter
    01/add                          3/mod/direct    3/rm32/ebx    .           .             .           1/r32/ecx   .               .                 # add ecx to ebx
    # ++counter
    41/increment-ecx
    # loop
    eb/jump  $loop/disp8

$exit:
    # exit(ebx)
    e8/call  syscall_exit/disp32

# . . vim:nowrap:textwidth=0