I’m banging my head trying to understand if this is a bug or the intended behavior.
I have a simple controller that is passing the content ff a blog post to the template
<?php
return function($site, $pages, $page) {
# Fetch Page Content
$posts = $page->children()->visible()->sortBy('published' , 'desc');
$post = $posts->first();
$title = $post->title();
$text = $post->text()->kt();
# Return the content
return compact('posts' , 'post' , 'title' , 'text');
};
In the template I then use a snippet to generate the post content
<?php snippet('post'); ?>
I tried both with and without variables passed as a second argument
In my snippet I then print the title as following
<h1 class="post-title"><?php e($page->isHomePage() , $title , "<a href='{$site->url()}'>{$title}</a>") ?></h1>
As a result I get this
<h1 class="post-title">
<a href="/">
<p>The Title</p>
</a>
</h1>
Where does that extra <p>
inside the link comes from?
I tried to get rid of it in every way possible. If I dump the value of the $title
variable, the content clearly doesn’t have the extra p attached. If I echo $title
(or $title->html()
or $title->value
) I still get the extra <p>
But, if inside my snippet I echo $page->title()
then the p
is gone.
Am I missing something here?