konstrui/README.md
README.mdRaw
1# Timmy [](https://goreportcard.com/report/github.com/arnaucode/timmy)
2
3web templating engine for static websites, written in Go lang
4
5
6
7
8
9## Example
10
11- Simple project structure example:
12
13```
14webInput/
15 index.html
16 templates/
17 userTemplate.html
18 userTemplate.json
19```
20
21- Set the html file:
22
23```html
24<!DOCTYPE html>
25<html>
26<body>
27
28<h1>My First Heading</h1>
29
30<p>My first paragraph.</p>
31
32<timmy-template html="templates/userTemplate.html" data="templates/userTemplate.json"></timmy-template>
33
34</body>
35</html>
36
37```
38
39
40- Set the template file:
41
42```html
43<div class="class1">
44 <div class="class2">{{username}}</div>
45 <div class="class2">{{description}}</div>
46 <div class="class2">{{phone}}</div>
47</div>
48```
49
50- Set the template data file:
51
52```json
53[{
54 "username": "Michaela Doe",
55 "description": "Hi, I'm here to code",
56 "phone": "456456456"
57 },
58 {
59 "username": "John Doe",
60 "description": "Hi, I'm here",
61 "phone": "123456789"
62 },
63 {
64 "username": "Myself",
65 "description": "How are you",
66 "phone": "no phone"
67 }
68]
69```
70
71- Set the configuration file timmyConfig.json in the webInput directory:
72
73```json
74{
75 "title": "Web example",
76 "author": "arnaucode",
77 "github": "github.com/arnaucode",
78 "website": "arnaucode.com",
79 "files": [
80 "index.html",
81 "projects.html",
82 "app.css"
83 ]
84}
85```
86
87
88- Execute Timmy
89
90```
91./timmy
92```
93
94- Output:
95
96```html
97<!DOCTYPE html>
98<html>
99
100<body>
101 <h1>My First Heading</h1>
102 <p>My first paragraph.</p>
103 <div class="class1">
104 <div class="class2">Michaela Doe</div>
105 <div class="class2">Hi, I'm here to code</div>
106 <div class="class2">456456456</div>
107 </div>
108 <div class="class1">
109 <div class="class2">John Doe</div>
110 <div class="class2">Hi, I'm here</div>
111 <div class="class2">123456789</div>
112 </div>
113 <div class="class1">
114 <div class="class2">Myself</div>
115 <div class="class2">How are you</div>
116 <div class="class2">no phone</div>
117 </div>
118</body>
119
120</html>
121```