-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
98 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# Example | ||
|
||
```twig | ||
{# | ||
Title: Testimonial | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Using examples | ||
From ACF 5.8.11 you can use **Example** to set example data for block previews. You can read more about this: | ||
- [https://developer.wordpress.org/block-editor/developers/block-api/block-registration/](https://developer.wordpress.org/block-editor/developers/block-api/block-registration/) | ||
|
||
To do this in **Timber ACF Blocks** you need to create your block like this: | ||
```twig | ||
{# | ||
Title: Testimonial | ||
Description: Customer testimonial | ||
Category: formatting | ||
Icon: admin-comments | ||
Keywords: testimonial quote "customer testimonial" | ||
Mode: edit | ||
Example: { "testimonial": "Testimonials", "author": "John Doe" } | ||
#} | ||
<blockquote> | ||
<p>{{ fields.testimonial }}</p> | ||
<cite> | ||
<span>{{ fields.author }}</span> | ||
</cite> | ||
</blockquote> | ||
``` | ||
In **Example** we only pass the fields and their values as a valid JSON. | ||
|
||
## Using static HTML as preview | ||
There are cases when we would like to use a static HTML as example. To do this create a file called `your-block-name-example.twig`. So if your block is called `testimonial.twig` than the example would be called `testimonial-example.twig`. | ||
|
||
This file would like this: | ||
```twig | ||
<blockquote> | ||
<p>Testimonial</p> | ||
<cite> | ||
<span>John Doe</span> | ||
</cite> | ||
</blockquote> | ||
``` | ||
|
||
You can also create an image preview and put it like this: | ||
```twig | ||
<img src="https://example.com/img/testominial-preview.jpg" alt="testimonial example"> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters