arnaucube
arnaucube/konstruiPublic Self-hosted repository
konstrui/README.md
README.mdRaw
  1# Timmy [![Go Report Card](https://goreportcard.com/badge/github.com/arnaucode/timmy)](https://goreportcard.com/report/github.com/arnaucode/timmy)
  2
  3web templating engine for static websites, written in Go lang
  4
  5
  6![timmy](https://raw.githubusercontent.com/arnaucode/timmy/master/timmy.png "timmy")
  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- Execute Timmy
 72
 73```
 74./timmy
 75```
 76
 77- Output:
 78
 79```html
 80<!DOCTYPE html>
 81<html>
 82
 83<body>
 84    <h1>My First Heading</h1>
 85    <p>My first paragraph.</p>
 86    <div class="class1">
 87        <div class="class2">Michaela Doe</div>
 88        <div class="class2">Hi, I'm here to code</div>
 89        <div class="class2">456456456</div>
 90    </div>
 91    <div class="class1">
 92        <div class="class2">John Doe</div>
 93        <div class="class2">Hi, I'm here</div>
 94        <div class="class2">123456789</div>
 95    </div>
 96    <div class="class1">
 97        <div class="class2">Myself</div>
 98        <div class="class2">How are you</div>
 99        <div class="class2">no phone</div>
100    </div>
101</body>
102
103</html>
104```