{"id":136299,"date":"2021-02-10T20:09:34","date_gmt":"2021-02-10T20:09:34","guid":{"rendered":"https:\/\/en-gb.wordpress.org\/plugins\/hatch\/"},"modified":"2022-04-11T10:57:14","modified_gmt":"2022-04-11T10:57:14","slug":"hatch","status":"closed","type":"plugin","link":"https:\/\/sq.wordpress.org\/plugins\/hatch\/","author":18401169,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.1.0","stable_tag":"1.1.0","tested":"5.9.13","requires":"4.7","requires_php":"7.0","requires_plugins":"","header_name":"Hatch","header_author":"A Big Egg","header_description":"Provides helper functions for working with Timber and ACF. Requires Timber (timber-library) and works well with Advanced Custom Fields Pro and Gravity Forms.","assets_banners_color":"","last_updated":"2022-04-11 10:57:14","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"","rating":0,"author_block_rating":0,"active_installs":0,"downloads":1332,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description"],"tags":{"0.2":{"tag":"0.2","author":"abigegg","date":"2021-02-10 20:15:45"},"0.3":{"tag":"0.3","author":"abigegg","date":"2021-02-10 20:47:19"},"0.4":{"tag":"0.4","author":"abigegg","date":"2021-02-10 20:47:19"},"0.4.1":{"tag":"0.4.1","author":"abigegg","date":"2021-02-12 18:25:34"},"0.4.2":{"tag":"0.4.2","author":"abigegg","date":"2021-02-12 18:25:34"},"0.4.3":{"tag":"0.4.3","author":"abigegg","date":"2021-02-12 23:51:14"},"0.4.4":{"tag":"0.4.4","author":"abigegg","date":"2021-02-19 16:44:42"},"0.5.5":{"tag":"0.5.5","author":"abigegg","date":"2021-06-24 21:03:59"},"0.6.0":{"tag":"0.6.0","author":"abigegg","date":"2021-06-28 14:02:10"},"0.6.1":{"tag":"0.6.1","author":"abigegg","date":"2021-11-24 17:51:16"},"0.6.2":{"tag":"0.6.2","author":"abigegg","date":"2022-03-28 22:09:35"},"1.0.0":{"tag":"1.0.0","author":"abigegg","date":"2022-03-31 12:15:19"},"1.1.0":{"tag":"1.1.0","author":"abigegg","date":"2022-04-11 10:57:14"}},"upgrade_notice":[],"ratings":[],"assets_icons":{"icon.svg":{"filename":"icon.svg","revision":2472657,"resolution":false,"location":"assets","locale":false}},"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.2","0.3","0.4","0.4.1","0.4.2","0.4.3","0.4.4","0.5.5","0.6.0","0.6.1","0.6.2","1.0.0","1.1.0"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[3772,15475,17809],"plugin_category":[],"plugin_contributors":[],"plugin_business_model":[],"class_list":["post-136299","plugin","type-plugin","status-closed","hentry","plugin_tags-developers","plugin_tags-templating","plugin_tags-timber","plugin_committers-abigegg"],"banners":[],"icons":{"svg":"https:\/\/ps.w.org\/hatch\/assets\/icon.svg?rev=2472657","icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/hatch.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Hatch is a helper library for developers which makes it more pleasant to build websites using Timber, Advanced Custom Fields Pro and other common plugins.<\/p>\n\n<h3>What is this thing?<\/h3>\n\n<p>Hatch is a helper library for developers which makes it more pleasant to build websites using Timber, Advanced Custom Fields Pro and other common plugins.<\/p>\n\n<h3>Requirements<\/h3>\n\n<p>Timber (latest version.)<\/p>\n\n<h3>A better way to use Timber<\/h3>\n\n<p>Using <a href=\"https:\/\/en-gb.wordpress.org\/plugins\/timber-library\/\">Timber<\/a> we can use Twig templates to build our sites rather than PHP.<\/p>\n\n<p>Typically we set up a Timber context like this:<\/p>\n\n<pre><code>$context = Timber::get_context();\n\n$context['post'] = Timber::get_post();\n\nfunction website_get_related_posts() {\n    \/\/ do something fancy here\n\n    return [];\n}\n\n$context['related_posts'] = website_get_related_posts();\n\nTimber::render( 'post.twig', $context );\n<\/code><\/pre>\n\n<p>This is <em>fine<\/em> but it can get a bit mucky - especially if we have complicated page templates with lots of variables.<\/p>\n\n<p>Hatch provides a tidier way of setting up contexts for Timber and other popular libraries:<\/p>\n\n<pre><code>\/\/ 'post' is already added by default\n\nHatch::add_context( 'related_posts', function() {\n    \/\/ do something fancy\n    return [];\n} );\n\nHatch::render( 'post.twig' ); \/\/ no need to pass $context in \n<\/code><\/pre>\n\n<p>More &amp; better documentation to come! Look in abe-hatch.php for more info<\/p>\n\n<h3>License<\/h3>\n\n<p>Copyright 2020 A Big Egg (David Hewitson Ltd)<\/p>\n\n<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and\/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:<\/p>\n\n<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.<\/p>\n\n<p>THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.%<\/p>","raw_excerpt":"Hatch is a helper library for developers which makes it more pleasant to build websites using Timber, Advanced Custom Fields Pro and other common plug &hellip;","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/136299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=136299"}],"author":[{"embeddable":true,"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/abigegg"}],"wp:attachment":[{"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=136299"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=136299"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=136299"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=136299"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=136299"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/sq.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=136299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}