@php // This logic should ideally be in the controller, but keeping it here for simplicity of the fix. $combined_css = ''; $combined_html = ''; // Sort sections by sort_order before combining $sortedSections = $template->sections->sortBy('sort_order'); foreach ($sortedSections as $section) { $combined_css .= $section->css_code; $combined_html .= $section->html_code; } // Basic placeholder replacement for preview $placeholders = ['name', 'email', 'phone', 'location', 'summary', 'position', 'company', 'start_date', 'end_date', 'description', 'degree', 'field_of_study', 'institution']; foreach ($placeholders as $placeholder) { $combined_html = preg_replace("/{{\s*{$placeholder}\s*}}/", ucfirst(str_replace('_', ' ', $placeholder)), $combined_html); } // Remove Handlebars block helpers for preview $combined_html = preg_replace('/{{#each \w+}}/', '', $combined_html); $combined_html = preg_replace('/{{\/each}}/', '', $combined_html); @endphp Template Preview {!! $combined_html !!}