Skip to content

Commit 430408c

Browse files
authored
(chore): Update README.md
1 parent b5e29a7 commit 430408c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ The Scribble GYB configuration simplifies boilerplate code generation for Scribb
1919

2020
3.3 [Conditional Logic](#conditional-logic)
2121

22+
3.4 [Loops](#loops)
23+
24+
4. [Using gyb_utils.py for Shared Utilities](#using-gyb-utils-py-for-shared-utilities)
25+
26+
4.1 [Declaring global variables](#declaring-global-utilities-in-gyb-utils-py)
27+
28+
4.2 [Importing and Using Utilities](#importing-and-using-utilities-in-gyb-templates)
29+
2230
## Overview
2331

2432
GYB (Generate Your Boilerplate) is a tool used to generate source code by mixing Python code with template files. It allows developers to avoid redundancy by dynamically generating patterns across different files or languages. Scribble GYB offers a powerful way to ensure clean, consistent code while minimizing manual coding effort.
@@ -192,6 +200,39 @@ struct User {
192200
193201
## Using gyb_utils.py for Shared Utilities
194202
203+
The `gyb_utils.py` file in the Scribble GYB configuration allows you to declare global variables, helper functions, or imports that can be reused across different GYB templates. This is especially useful when you have common logic or variables that need to be shared.
204+
205+
### Declaring Global Utilities in `gyb_utils.py`
206+
207+
You can modify the `gyb_utils.py` file to declare any utility functions, global variables, or imports. For example, you can declare shared constants or utility functions like this:
208+
209+
```py
210+
# gyb_utils.py
211+
PI = 3.14159
212+
213+
def square(x):
214+
return x * x
215+
```
216+
217+
### Importing and Using Utilities in GYB Templates
218+
219+
Once you have your utilities declared, you can import them into any GYB template by using a simple Python import statement at the top of your template:
220+
221+
```py
222+
%{
223+
from gyb_utils import *
224+
}%
225+
226+
print("The value of PI is ${PI}")
227+
print("The square of 4 is ${square(4)}")
228+
```
229+
230+
This allows you to maintain clean, reusable code in your GYB templates, avoiding redundancy and making your templates more maintainable.
231+
232+
## Using GYB with Objective-C and Objective-C++
233+
234+
235+
195236
196237
### Running Scribble-GYB
197238

0 commit comments

Comments
 (0)