-
Notifications
You must be signed in to change notification settings - Fork 180
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
Conversation
section mode handling is still missing though
src/Template/TemplateSection.php
Outdated
throw new \InvalidArgumentException("Only same section may be merged"); | ||
} | ||
|
||
$this->mutationlog = array_merge($this->mutationlog, $other->mutationlog); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
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.