Added sections inheritance of fetched templates while retaining mutation mode#310
Closed
Abdillah wants to merge 9 commits into
Closed
Added sections inheritance of fetched templates while retaining mutation mode#310Abdillah wants to merge 9 commits into
Abdillah wants to merge 9 commits into
Conversation
section mode handling is still missing though
Abdillah
commented
Mar 27, 2023
| throw new \InvalidArgumentException("Only same section may be merged"); | ||
| } | ||
|
|
||
| $this->mutationlog = array_merge($this->mutationlog, $other->mutationlog); |
Author
There was a problem hiding this comment.
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.
Author
There was a problem hiding this comment.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_REWRITEmode or just break at the first attempt or some other alternative behavior.