- if ($matchedPage === null) {
- $html = str_replace($fullMatch, '', $html);
- continue;
+ $replacement = '';
+
+ if ($matchedPage && count($splitInclude) === 1) {
+ // If we only have page id, just insert all page html and continue.
+ $replacement = $matchedPage->html;
+ } elseif ($matchedPage && count($splitInclude) > 1) {
+ // Otherwise, if our include tag defines a section, load that specific content
+ $innerContent = $this->fetchSectionOfPage($matchedPage, $splitInclude[1]);
+ $replacement = trim($innerContent);