-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation: Initial matchers documentation #1499
Conversation
blocks/README.md
Outdated
|
||
Given the block's HTML content as a string, attribute matchers extract the block attributes values into an Object. The matchers are made available throught the `wp.blocks.query` variable. | ||
|
||
In addition to all [HPQ](http://github.com/aduth/hpq)'s matchers, we provide these extra matchers to ease working with HTML content: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include the HPQ documentation here directly?
An "examples" section would be great, we'll need real-case variations. Let's get the docs merged first and then look at examples. |
|
||
`attr( selector: ?string, name: string ): Function` | ||
|
||
Generates a matcher function, returning an attribute by name if the attribute exists. If no selector is passed, returns attribute of the root element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit confusing. Can we explain it simpler? If an attributes exists where? Maybe we can change the phrasing to be more about: "Use attr
when you want to extract y from x`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd appreciate some help phrasing here. I'm not very good at that 😅
|
||
`html( selector: ?string ): Function` | ||
|
||
Convenience for `prop( selector, 'innerHTML' )` . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
Use when you want to get the raw html within the block as a single attribute. Convenience for prop( selector, 'innerHTML' )
".
closing in favor of #1786 |
refs #1419
This adds a "Matchers" section to the blocks module documentation. It exposes the matchers available for now (redirecting to HPQ for HPQ's built-in matchers).
I think we'd need a separate "Examples" sections showing the different kind of blocks we can build using the matchers and the components provided.