Skip to content

Duplicate code with nested sections #49

@janwalther

Description

@janwalther

I have the following setup:
The layout defines sections:

<!DOCTYPE html>
<html>
<head>
    <title><?= $this->e('title') ?></title>
    <?php $this->section('head'); $this->stop(); ?>
</head>
<body>

<?php $this->section('content');$this->stop(); ?>

<?php $this->section('end-body');$this->stop(); ?>
</body>
</html>

Then there is the template appending some content to the content section of the layout. Some of the content is loaded by including a partial:

<?php $this->layout('layout::page', ['title' => 'Page title']) ?>

<?php $this->section('content') ?>
<h1>Test</h1>

<?= $this->insert('partials::date-input'); ?>
<?php $this->append() ?>

The partial references a JS file (which should be appended to the "end-body" section of the layout) and some HTML which should be inserted whereever $this->insert('partial-name') is called.

<?php $this->section('end-body') ?>
<script src="/jquery.min.js"></script>
<script src="/intercooler.js"></script>
<?php $this->append() ?>

<div ic-get-from="<url>" ic-trigger-on="scrolled-into-view"></div>

The result is:

<!DOCTYPE html>
<html>
<head>
    <title>Page title</title>
    </head>
<body>

<h1>Test</h1>

<script src="/jquery.min.js"></script>
<script src="/intercooler.js"></script>

<div ic-get-from="<url>" ic-trigger-on="scrolled-into-view"></div>

<script src="/jquery.min.js"></script>
<script src="/intercooler.js"></script>
</body>
</html>

So the JS files get embedded twice.
I am quite sure that I did something wrong but perhaps this really is a bug.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions