Add getPureContent
to Page to be able to get content without template
This commit is contained in:
parent
d8f7a6e238
commit
55ef0b982b
@ -15,4 +15,9 @@ abstract class ComputedRawPage implements Page
|
|||||||
{
|
{
|
||||||
return $this->raw->getContent();
|
return $this->raw->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPureContent()
|
||||||
|
{
|
||||||
|
return $this->raw->getContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ abstract class ContentPage extends SimplePage
|
|||||||
*/
|
*/
|
||||||
protected $contentType;
|
protected $contentType;
|
||||||
|
|
||||||
|
protected $generatedContent;
|
||||||
|
|
||||||
public function __construct($title, $content)
|
public function __construct($title, $content)
|
||||||
{
|
{
|
||||||
$this->initializePage($title, $content);
|
$this->initializePage($title, $content);
|
||||||
@ -49,14 +51,18 @@ abstract class ContentPage extends SimplePage
|
|||||||
$this->contentType = $contentType;
|
$this->contentType = $contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function convertPage($content)
|
public function getPureContent()
|
||||||
{
|
{
|
||||||
return $this->contentType->convert($content, $this->getFile());
|
if (!$this->generatedContent) {
|
||||||
|
$this->generatedContent = $this->contentType->convert($this->content, $this->getFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->generatedContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generatePage()
|
protected function generatePage()
|
||||||
{
|
{
|
||||||
return $this->convertPage($this->content);
|
return $this->getPureContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromFile(Content $file, $params, ContentType $contentType)
|
public static function fromFile(Content $file, $params, ContentType $contentType)
|
||||||
|
@ -2,5 +2,17 @@
|
|||||||
|
|
||||||
interface Page
|
interface Page
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get the converted content, without any template
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPureContent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the full content
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function getContent();
|
public function getContent();
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,11 @@ abstract class RawPage implements Page
|
|||||||
return $this->file;
|
return $this->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPureContent()
|
||||||
|
{
|
||||||
|
throw new Exception("you should not use this method to show a raw content");
|
||||||
|
}
|
||||||
|
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
throw new Exception("you should not use this method to show a raw content");
|
throw new Exception("you should not use this method to show a raw content");
|
||||||
|
@ -11,6 +11,11 @@ abstract class SimplePage implements Page
|
|||||||
$this->initializePage($title, $content);
|
$this->initializePage($title, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPureContent()
|
||||||
|
{
|
||||||
|
return $this->content;
|
||||||
|
}
|
||||||
|
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
if (is_null($this->generated)) {
|
if (is_null($this->generated)) {
|
||||||
|
@ -81,7 +81,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
|||||||
'modified_time' => filemtime($this->file->getPath()),
|
'modified_time' => filemtime($this->file->getPath()),
|
||||||
'markdown' => $this->content,
|
'markdown' => $this->content,
|
||||||
'request' => $params['request'],
|
'request' => $params['request'],
|
||||||
'content' => $this->convertPage($this->content),
|
'content' => $this->getPureContent(),
|
||||||
'breadcrumbs' => $params['html']['breadcrumbs'],
|
'breadcrumbs' => $params['html']['breadcrumbs'],
|
||||||
'prev' => $this->file->getPrevious(),
|
'prev' => $this->file->getPrevious(),
|
||||||
'next' => $this->file->getNext(),
|
'next' => $this->file->getNext(),
|
||||||
|
@ -33,7 +33,7 @@ class ErrorPage extends SimplePage
|
|||||||
$params = $this->params;
|
$params = $this->params;
|
||||||
$page = [
|
$page = [
|
||||||
'title' => $this->title,
|
'title' => $this->title,
|
||||||
'content' => $this->content,
|
'content' => $this->getPureContent(),
|
||||||
'language' => '',
|
'language' => '',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user