Use the "end_section" html helper for better clarify on when a section starts and when it ends

This commit is contained in:
Alex Tselegidis 2023-03-13 08:24:43 +01:00
parent 453c6e1302
commit 7be4c73e4e
31 changed files with 89 additions and 53 deletions

View file

@ -127,6 +127,42 @@ if ( ! function_exists('section'))
}
}
if ( ! function_exists('end_section'))
{
/**
* Use this function in view files to mark the end of a layout section.
*
* Sections will only be used if the view file extends a layout and will be ignored otherwise.
*
* Example:
*
* <?php section('content') ?>
*
* <!-- Section Starts -->
*
* <p>This is the content of the section.</p>
*
* <!-- Section Ends -->
*
* <?php end_section('content') ?>
*
* @param string $name
*/
function end_section(string $name)
{
$layout = config('layout');
if (array_key_exists($name, $layout['tmp']))
{
$layout['sections'][$name][] = ob_get_clean();
unset($layout['tmp'][$name]);
config(['layout' => $layout]);
}
}
}
if ( ! function_exists('slot'))
{
/**

View file

@ -19,4 +19,4 @@
<script src="<?= asset_url('assets/js/components/appointment_status_options.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -360,4 +360,4 @@
<script src="<?= asset_url('assets/js/components/appointments_modal.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -8,7 +8,7 @@
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/css/components/color_selection.css') ?>">
<?php section('styles') ?>
<?php end_section('styles') ?>
<label class="form-label"><?= lang('color') ?></label>
@ -62,4 +62,4 @@
<script src="<?= asset_url('assets/js/components/color_selection.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -89,4 +89,4 @@
<script src="<?= asset_url('assets/js/components/unavailabilities_modal.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -64,4 +64,4 @@
<script src="<?= asset_url('assets/js/components/working_plan_exceptions_modal.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -95,4 +95,4 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>

View file

@ -182,7 +182,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -191,4 +191,4 @@
<script src="<?= asset_url('assets/js/http/account_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/account.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -222,7 +222,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -233,5 +233,5 @@
<script src="<?= asset_url('assets/js/http/admins_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/admins.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -51,7 +51,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -59,4 +59,4 @@
<script src="<?= asset_url('assets/js/http/api_settings_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/api_settings.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -47,7 +47,7 @@
'display_privacy_policy' => vars('display_privacy_policy'),
]) ?>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -61,4 +61,4 @@
<script src="<?= asset_url('assets/js/http/booking_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/booking.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -19,12 +19,12 @@
</a>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
<?php component('google_analytics_script', ['google_analytics_code' => vars('google_analytics_code')]) ?>
<?php component('matomo_analytics_script', ['matomo_analytics_url' => vars('matomo_analytics_url')]) ?>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -30,11 +30,11 @@
</a>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
<?php component('google_analytics_script', ['google_analytics_code' => vars('google_analytics_code')]) ?>
<?php component('matomo_analytics_script', ['matomo_analytics_url' => vars('matomo_analytics_url')]) ?>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -12,12 +12,12 @@
<p><?= vars('message_text') ?></p>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
<?php component('google_analytics_script', ['google_analytics_code' => vars('google_analytics_code')]) ?>
<?php component('matomo_analytics_script', ['matomo_analytics_url' => vars('matomo_analytics_url')]) ?>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -365,7 +365,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -373,7 +373,7 @@
<script src="<?= asset_url('assets/js/http/booking_settings_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/booking_settings.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -123,7 +123,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -136,5 +136,5 @@
<script src="<?= asset_url('assets/js/http/business_settings_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/business_settings.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -109,7 +109,7 @@
<?php component('working_plan_exceptions_modal') ?>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -130,5 +130,5 @@
<script src="<?= asset_url('assets/js/http/customers_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/calendar.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -82,7 +82,7 @@
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -92,4 +92,4 @@
<script src="<?= asset_url('assets/js/http/categories_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/categories.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -198,7 +198,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -209,4 +209,4 @@
<script src="<?= asset_url('assets/js/http/customers_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/customers.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -200,7 +200,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -208,4 +208,4 @@
<script src="<?= asset_url('assets/js/http/general_settings_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/general_settings.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -52,7 +52,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -60,4 +60,4 @@
<script src="<?= asset_url('assets/js/http/google_analytics_settings_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/google_analytics_settings.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -113,5 +113,5 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>

View file

@ -81,7 +81,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -91,4 +91,4 @@
<script src="<?= asset_url('assets/js/pages/legal_settings.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -37,7 +37,7 @@
</button>
</div>
</form>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -46,4 +46,4 @@
<script src="<?= asset_url('assets/js/http/login_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/login.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -22,6 +22,6 @@
</a>
</div>
<?php section('content') ?>
<?php end_section('content') ?>

View file

@ -52,7 +52,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -60,4 +60,4 @@
<script src="<?= asset_url('assets/js/http/matomo_analytics_settings_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/matomo_analytics_settings.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -355,7 +355,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -371,7 +371,7 @@
<script src="<?= asset_url('assets/js/http/providers_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/providers.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -41,7 +41,7 @@
</div>
</form>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -51,4 +51,4 @@
<script src="<?= asset_url('assets/js/http/recovery_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/recovery.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -231,7 +231,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -242,5 +242,5 @@
<script src="<?= asset_url('assets/js/http/secretaries_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/secretaries.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -166,7 +166,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -177,4 +177,4 @@
<script src="<?= asset_url('assets/js/http/categories_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/services.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>

View file

@ -141,7 +141,7 @@
</div>
</div>
<?php section('content') ?>
<?php end_section('content') ?>
<?php section('scripts') ?>
@ -151,4 +151,4 @@
<script src="<?= asset_url('assets/js/http/webhooks_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/webhooks.js') ?>"></script>
<?php section('scripts') ?>
<?php end_section('scripts') ?>