Skip to content

Commit fe2971e

Browse files
committed
Syntax highligting
1 parent 4909198 commit fe2971e

File tree

19 files changed

+46
-45
lines changed

19 files changed

+46
-45
lines changed

docs/components/forms.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Use the `Form` component with a form object to write the form tag. Use `HxForm` instead of `Form` for an HTMX powered form instead.
44

5-
```
5+
```jinja
66
<{Form form action="..."}>
77
88
</{Form}>
@@ -13,7 +13,7 @@ Use the `Form` component with a form object to write the form tag. Use `HxForm`
1313

1414
Use `FormField` components to style fields properly:
1515

16-
```
16+
```jinja
1717
<{Form form}>
1818
<{FieldsetLegend}>Login</{}>
1919
@@ -30,7 +30,7 @@ Use the `form-w-full` call on the form tag for full width forms.
3030

3131
Follow the DaisyUI pattern:
3232

33-
```
33+
```jinja
3434
<{Fieldset}>
3535
<{FieldsetLegend}>Login</{}>
3636

docs/components/icons.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Icons are provided by [Bootstrap Icons](https://icons.getbootstrap.com).
44

55
Use the `Icon` component and provide the icon name:
66

7-
```
7+
```jinja
88
<{Icon "cart" }/>
99
```

docs/components/layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Hyperflask includes a few utilties to help you design your app quickly.
66

77
Use the following snippet to kick start a very common application UI with a sidebar:
88

9-
```
9+
```jinja
1010
<{AppUI}>
1111
<{Viewport}>
1212

docs/components/modals.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Use the `Modal` component to create an [HTML dialog element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog).
44

5-
```
5+
```jinja
66
<{Button onclick="modal1.showModal()" }>Say hello</{Button}>
77
<{Modal id="modal1"}>
88
<{ModalTitle}>Hello!</{ModalTitle}>
@@ -21,7 +21,7 @@ Create a backend-driven modal that auto opens when called. Uses the built-in hf-
2121

2222
Example *components/SignupModal.jpy*:
2323

24-
```
24+
```jpy
2525
---
2626
from hyperflask import htmx_redirect
2727
@@ -52,6 +52,6 @@ Using `<{ModalForm}>` ensures that the modal closes on successfull submit. When
5252

5353
In a page:
5454

55-
```
55+
```jinja
5656
<{Button hf_modal=url_for('SignupModal')}>Signup</{}>
5757
```

docs/getting-started.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ In your project folder, you will find the following files and folders:
8181

8282
First, let's create a basic chat window with some messages. Replace the content of `app/pages/index.jpy` with the following:
8383

84-
```
84+
```jinja
8585
{% use_layout %}
8686
<div id="messages">
8787
<{ChatBubble}>First message!</{ChatBubble}>
@@ -104,7 +104,7 @@ Now that we have the basic layout of our app, let's extract the chat bubble as a
104104

105105
We are going to create a `ChatMessage` component to render one message. In `app/components/ChatMessage.jpy`:
106106

107-
```
107+
```jpy
108108
---
109109
from hyperflask import request
110110
@@ -124,7 +124,7 @@ The function then returns the properties that will be used to render the compone
124124

125125
Let's add a form to our chat interface. Replace `app/pages/index.jpy` with the following:
126126

127-
```
127+
```jinja
128128
{% use_layout %}
129129
<div id="messages">
130130
{# messages will display here #}
@@ -158,7 +158,7 @@ class Message(db.Model):
158158

159159
Modify our component to save messages:
160160

161-
```
161+
```jpy
162162
---
163163
from hyperflask import request
164164
from app.models import db, Message
@@ -175,7 +175,7 @@ def post():
175175

176176
And finally the page:
177177

178-
```
178+
```jpy
179179
---
180180
from app.models import Message
181181
@@ -201,7 +201,7 @@ Rather than sending back a message partial when posting a new message, we will u
201201

202202
Modify the `ChatMessage` component back to its simpler state:
203203

204-
```
204+
```jinja
205205
<{ChatBubble}>
206206
{{props.message.message|markdown}}
207207
</{ChatBubble}>
@@ -211,7 +211,7 @@ Now let's create a new component `PostMessageForm` in `app/components/PostMessag
211211

212212
We will also use the a [form](/guides/forms) in this component to easily validate data.
213213

214-
```
214+
```jpy
215215
---
216216
from hyperflask import page, current_app
217217
from app.models import db, Message
@@ -232,7 +232,7 @@ def post():
232232

233233
Let's modify `app/pages/index.jpy` to use our new component and connect to the SSE stream:
234234

235-
```
235+
```jpy
236236
---
237237
from app.models import Message
238238
@@ -277,7 +277,7 @@ class Message(UserRelatedMixin, db.Model):
277277

278278
Modify the component `ChatMessage` to display the author:
279279

280-
```
280+
```jinja
281281
<{ChatBubble header=props.message.user.email}>
282282
{{props.message.message|markdown}}
283283
</{ChatBubble}>

docs/guides/components.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Components can recieve parameters named *props*.
1414

1515
For example, to create a dropdown component, let's create the file *app/components/Dropdown.html*:
1616

17-
```html
17+
```jinja
1818
<div class="dropdown">
1919
<button>{{props.label}}</button>
2020
<ul class="dropmenu">
@@ -42,7 +42,7 @@ Back to our example:
4242

4343
Now, let's rework our component to use another component for the dropdown items.
4444

45-
```html
45+
```jinja
4646
<div class="dropdown">
4747
<button>{{props.label}}</button>
4848
<ul class="dropmenu">
@@ -53,15 +53,15 @@ Now, let's rework our component to use another component for the dropdown items.
5353

5454
Now create *app/components/DropdownItem.html*:
5555

56-
```html
56+
```jinja
5757
<li>
5858
<a href="{{prop.url}}">{{children()}}</a>
5959
</li>
6060
```
6161

6262
And finally, let's create a dropdown:
6363

64-
```
64+
```jinja
6565
<{Dropdown label="Countries"}>
6666
<{DropdownItem url=url_for('countries', code="fr")}>France</{DropdownItem}>
6767
<{DropdownItem url=url_for('countries', code="hk")}>Hong Kong</{DropdownItem}>
@@ -80,7 +80,7 @@ HTML components can have their own custom backend logic. Read on to the [next gu
8080

8181
Example using the previous *app/components/Dropdown.html*:
8282

83-
```html
83+
```jinja
8484
<div class="dropdown" x-data="{ open: false }">
8585
<button @click="open = true">{{props.label}}</button>
8686
<ul class="dropmenu" x-show="open">
@@ -156,7 +156,7 @@ Use a jinjapy file instead of html file (.jpy extension) and implement the rende
156156

157157
The render function will be provided the props as arguments.
158158

159-
```
159+
```jpy
160160
---
161161
def render(prop1, prop2):
162162
# custom logic

docs/guides/emails.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Email templates are located in the *app/emails* folder. The recommended format i
1111

1212
Template files can contain a YAML frontmatter with extra metadata like subject. The frontmatter values are templated as well.
1313

14-
```
14+
```jinja
1515
---
1616
subject: "Welcome {{name}} to example.com!"
1717
---

docs/guides/files.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MyModel(db.Model):
1818

1919
In a page using a form:
2020

21-
```
21+
```jpy
2222
---
2323
form = page.form()
2424
def post():
@@ -42,7 +42,7 @@ When accessing the model property, the value is a [file object](https://github.c
4242

4343
To generate a url for the file:
4444

45-
```
45+
```jpy
4646
---
4747
page.obj = MyModel.get(1)
4848
---
@@ -72,7 +72,7 @@ files_base_path: bucket_name
7272

7373
Use `save_file()` to store a file and get a [file object](https://github.com/hyperflask/flask-files#file-object). File objects are serializable as string or JSON.
7474

75-
```
75+
```jpy
7676
---
7777
from hyperflask import save_file
7878

docs/guides/flash.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Flask [provides a mechanism](https://flask.palletsprojects.com/en/stable/pattern
44

55
Use `flash()` or `page.flash()` as described by Flask documentation.
66

7-
```
7+
```jpy
88
---
99
page.flash("Welcome to my page!", "success")
1010
---

docs/guides/forms.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Easily define forms that can be validated on the frontend and the backend.
99

1010
Create forms in templates by calling fields on a `form` object as if they would be already declared. The syntax for calling fields is slightly different compared to raw wtforms as it also includes the field type.
1111

12-
```
12+
```jinja
1313
{# signup.html #}
1414
<{Form form}>
1515
<{FormField form.firstname.text("First name") }/>
@@ -37,7 +37,7 @@ To make things easier, when using pages, forms declared inside pages are availab
3737

3838
Example page:
3939

40-
```
40+
```jpy
4141
---
4242
form = page.form()
4343
def post():

0 commit comments

Comments
 (0)