Generate ACF Gutenberg blocks just by adding templates to your Sage theme. This package is based heavily on this article by nicoprat.
Run the following in your Sage 9-based theme directory:
composer require "mwdelaney/sage-acf-gutenberg-blocks"
Add blade templates to views/blocks
which get and use ACF data. Each template requires a comment block with some data in it:
{{--
Title:
Description:
Category:
Icon:
Keywords:
Mode:
PostTypes:
--}}
{{--
Title: Testimonial
Description: Customer testimonial
Category: formatting
Icon: admin-comments
Keywords: testimonial quote
Mode: edit
PostTypes: page post
--}}
<blockquote data-{{ $block['id'] }} class="{{ $block['classes'] }}">
<p>{{ get_field('testimonial') }}</p>
<cite>
<span>{{ get_field('author') }}</span>
</cite>
</blockquote>
<style type="text/css">
[data-{{$block['id']}}] {
background: {{ get_field('background_color') }};
color: {{ get_field('text_color') }};
}
</style>
Once a block is created you'll be able to assign ACF fields to it using the standard Custom Fields interface in WordPress. We recommend using sage-advanced-custom-fields to keep your ACF fields in version control with Sage.