Skip to content

Conversation

axelknock
Copy link
Contributor

I think copy-pastable code is a nice experience for getting started with a library, even when it's not applicable to the particular framework I'm using (everything is pretty generalizable anyway), so I made the few snippets in the readme closer to runnable code. The first snippet can be run if dependencies are present.

I also modified the syntax of the FastHTML data.on attribute generation (I figure since the release is out this also doesn't need the disclaimer anymore).

Copy link
Collaborator

@gazpachoking gazpachoking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems pretty good. I'm slightly hesitant because I think the extra boilerplate hides the Datastar stuff we are trying to showcase, but I don't think it ends up too bad.

Button("My Button", **data.on("click", "console.log('clicked')").debounce(1000).stop)
# After next release of FastHTML you don't have to unpack the datastar helpers e.g.
Button("My Button", data.on("click", "console.log('clicked')").debounce(1000).stop)
Button(data.on("click", "console.log('clicked')").debounce(1000).stop)("My Button")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new format? I don't see any documentation about it. (Nor for the dictionary form we used above for that matter.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attributes first has actually been in FastHTML for a while, but I do not think it's documented anywhere. The only place I could find it was inside this idiomatic FastHTML app Jeremy Howard recently rewrote:
https://github.com/AnswerDotAI/fasthtml/blob/main/examples/adv_app.py
It's some people's preference because it looks closer to HTML, but the default is the pythonic way of passing everything as arguments to a FT function.
The dict method is demoed here:
https://fastht.ml/docs/explains/explaining_xt_components.html#attributes

@gazpachoking
Copy link
Collaborator

Unrelated to your change I started thinking we should start off with an example that uses all the nice features. Right now we start off with an example than shows you barely have to use any of the features the SDK gives you. 😆

@axelknock
Copy link
Contributor Author

You're right I think that the first example should probably demonstrate everything that is on offer in one block, and then break down all of the components afterwards.

@gazpachoking gazpachoking merged commit 0a666dd into starfederation:develop Jul 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants