Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sections inheritance of fetched templates while retaining mutation mode #310

Closed
wants to merge 9 commits into from
Closed

Added sections inheritance of fetched templates while retaining mutation mode #310

wants to merge 9 commits into from

Conversation

Abdillah
Copy link

Based on #306, implements section as history of mutation. There is an uncertainty in my implementation details: whether to allow multiple mutation with Template::SECTION_MODE_REWRITE mode or just break at the first attempt or some other alternative behavior.

throw new \InvalidArgumentException("Only same section may be merged");
}

$this->mutationlog = array_merge($this->mutationlog, $other->mutationlog);
Copy link
Author

@Abdillah Abdillah Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still unsure on what to do if multiple rewrites exist, some in the right mutationlog. If we simply merge, the operation on $this->mutationlog will be lost even if APPEND and PREPEND exists.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking of grouping REWRITE before any mutation. That is consistent with what template system should do in my mind.

layout.php

<?php $this->section('javascript') ?>

page.php

<?php $this->layout('layout') ?>

<?php $this->start('javascript') ?>
  <script src="base-page-script-very-light-weight.js"></script>
<?php $this->end() ?>

<?= $this->fetch('common-component-a') ?>
<?= $this->fetch('heavyweight-component-b') ?>

heavyweight-component-b.php

<?php $this->start('javascript') ?>
  <script src="base-page-script-support-heavy-weight.js"></script>
<?php $this->end() ?>

common-component-a.php

<?php $this->push('javascript') ?>
  <script src="common-component-a.js"></script>
<?php $this->end() ?>

The end result will be,

<script src="base-page-script-support-heavy-weight.js"></script>
<script src="common-component-a.js"></script>

@Abdillah Abdillah closed this by deleting the head repository Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants