Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

youknowriad
Copy link
Contributor

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.

@youknowriad youknowriad added the [Type] Developer Documentation Documentation for developers label Jun 27, 2017
@youknowriad youknowriad self-assigned this Jun 27, 2017
@youknowriad youknowriad requested a review from mtias June 27, 2017 12:55
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:
Copy link
Member

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?

@mtias
Copy link
Member

mtias commented Jun 27, 2017

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.
Copy link
Member

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`.

Copy link
Contributor Author

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' )` .
Copy link
Member

@mtias mtias Jun 28, 2017

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' )".

@youknowriad
Copy link
Contributor Author

closing in favor of #1786

@ntwb ntwb deleted the add/matchers-documentation branch August 5, 2017 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants