|
1 | 1 | # ✍️ MiniTemplate - Simple Template Engine |
2 | 2 |
|
3 | | -This guide will walk you through setting up a MiniTemplate project, converting components, adding templates, and finally generating a static `index.html` file. The setup is divided into several parts to ease integration and usage. |
| 3 | +This guide will walk you through setting up a MiniTemplate project, adding components, templates, and finally generating a static `index.html` file. The setup is streamlined to make it easy for developers to test and get started quickly. |
4 | 4 |
|
5 | 5 | ## Directory Structure Overview |
6 | 6 |
|
@@ -90,50 +90,7 @@ You can also add all default components by running: |
90 | 90 |
|
91 | 91 | This command copies all default components (like header, footer, sidebar, etc.) into your project directory. |
92 | 92 |
|
93 | | -## Step 3: Converting Source Components |
94 | | - |
95 | | -MiniTemplate allows you to transform raw components from `components/source` (which are basic DaisyUI HTML components) into usable MiniTemplate components in `components/converted`. |
96 | | - |
97 | | -### Convert Components |
98 | | - |
99 | | -Navigate to the `scripts` directory and use the `convert_components.sh` script to convert all raw components: |
100 | | - |
101 | | -```bash |
102 | | -cd ./scripts && ./convert_components.sh |
103 | | -``` |
104 | | - |
105 | | -This will read all HTML files in the `source` directory and convert them into self-contained components, which will be placed in the `converted` directory. |
106 | | - |
107 | | -### Structure Comparison: Source vs Converted |
108 | | - |
109 | | -- **Source Component Example (Basic DaisyUI HTML):** |
110 | | - |
111 | | - ```html |
112 | | - <div class="alert"> |
113 | | - <span>Alert message here!</span> |
114 | | - </div> |
115 | | - ``` |
116 | | - |
117 | | -- **Converted Component Example (MiniTemplate Component):** |
118 | | - |
119 | | - ```html |
120 | | - <div id="alert_component"> |
121 | | - <div class="alert"> |
122 | | - <span>Alert message here!</span> |
123 | | - </div> |
124 | | - <script> |
125 | | - (function() { |
126 | | - // Component-specific JavaScript |
127 | | - })(); |
128 | | - </script> |
129 | | - </div> |
130 | | - ``` |
131 | | - |
132 | | -### Benefits of Conversion |
133 | | - |
134 | | -The converted components are self-contained and modular, allowing for easy reuse and consistent styling throughout your project. Each component includes a JavaScript block for additional behavior, making them more powerful compared to the basic DaisyUI HTML. |
135 | | - |
136 | | -## Step 4: Adding Template Variables and Generating the Static Site |
| 93 | +## Step 3: Adding Template Variables and Generating the Static Site |
137 | 94 |
|
138 | 95 | Once you have all the necessary components in place, you can integrate them into your templates using the `{{component_name}}` syntax. This allows for nesting components within templates or even within other components. |
139 | 96 |
|
@@ -186,7 +143,7 @@ Here is an example of how `{{}}` placeholders are used within a template file: |
186 | 143 |
|
187 | 144 | In this example, the `{{header_default}}`, `{{button}}`, and `{{footer_default}}` placeholders are replaced with their respective component contents during the generation process. |
188 | 145 |
|
189 | | -## Step 5: Testing the Setup |
| 146 | +## Step 4: Testing the Setup |
190 | 147 |
|
191 | 148 | You can run a suite of tests to ensure that your setup is working as expected. |
192 | 149 |
|
@@ -230,3 +187,46 @@ If all tests pass, you’ll receive a success message. If any tests fail, check |
230 | 187 |
|
231 | 188 | Refer to [CONTRIBUTE.md](../CONTRIBUTE.md) for guidelines on how to contribute and see [LICENSE](../LICENSE) for licensing information. |
232 | 189 |
|
| 190 | +## Additional Step: Converting Source Components (Optional) |
| 191 | + |
| 192 | +MiniTemplate allows you to transform raw components from `components/source` (which are basic DaisyUI HTML components) into usable MiniTemplate components in `components/converted`. |
| 193 | + |
| 194 | +### Convert Components |
| 195 | + |
| 196 | +Navigate to the `scripts` directory and use the `convert_components.sh` script to convert all raw components: |
| 197 | + |
| 198 | +```bash |
| 199 | +cd ./scripts && ./convert_components.sh |
| 200 | +``` |
| 201 | + |
| 202 | +This will read all HTML files in the `source` directory and convert them into self-contained components, which will be placed in the `converted` directory. |
| 203 | + |
| 204 | +### Structure Comparison: Source vs Converted |
| 205 | + |
| 206 | +- **Source Component Example (Basic DaisyUI HTML):** |
| 207 | + |
| 208 | + ```html |
| 209 | + <div class="alert"> |
| 210 | + <span>Alert message here!</span> |
| 211 | + </div> |
| 212 | + ``` |
| 213 | + |
| 214 | +- **Converted Component Example (MiniTemplate Component):** |
| 215 | + |
| 216 | + ```html |
| 217 | + <div id="alert_component"> |
| 218 | + <div class="alert"> |
| 219 | + <span>Alert message here!</span> |
| 220 | + </div> |
| 221 | + <script> |
| 222 | + (function() { |
| 223 | + // Component-specific JavaScript |
| 224 | + })(); |
| 225 | + </script> |
| 226 | + </div> |
| 227 | + ``` |
| 228 | + |
| 229 | +### Benefits of Conversion |
| 230 | + |
| 231 | +The converted components are self-contained and modular, allowing for easy reuse and consistent styling throughout your project. Each component includes a JavaScript block for additional behavior, making them more powerful compared to the basic DaisyUI HTML. |
| 232 | + |
0 commit comments