You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
2.2 KiB

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