<?php

use Timber\Timber;

$context = Timber::context();
$context['post'] = Timber::get_post();

$postId = isset($context['post']->ID) ? (int) $context['post']->ID : 0;
$raw = $postId > 0 ? (string) get_post_field('post_content', $postId) : '';

// Force the Gutenberg/ACF block rendering pipeline.
$context['content'] = apply_filters('the_content', $raw);

$postType = $context['post']->post_type ?? '';
$templates = [];

if (is_string($postType) && $postType !== '') {
    $templates[] = 'views/single-' . $postType . '.twig';
}

$templates[] = 'views/single.twig';

Timber::render($templates, $context);