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.

122 lines
2.3 KiB

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