public function MarkdownExporter::compile in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/MarkdownExporter.php \AKlump\LoftDataGrids\MarkdownExporter::compile()
Build the string content of $this->output and return $this for chaining.
Parameters
mixed $page_id: (Optional) Defaults to NULL. Set this to only compile a single page.
Return value
$this
Overrides ExporterInterface::compile
File
- vendor/
aklump/ loft_data_grids/ src/ AKlump/ LoftDataGrids/ MarkdownExporter.php, line 23
Class
- MarkdownExporter
- Class MarkdownExporter
Namespace
AKlump\LoftDataGridsCode
public function compile($page_id = null) {
$pages = $this
->getData()
->get();
$this->output = '';
$multi = count($pages) > 1 ? '#' : '';
$output = '';
foreach ($pages as $page_id => $page) {
if ($multi) {
$output .= "{$multi}# Page " . ($page_id + 1) . "\n";
}
foreach ($page as $record_id => $record) {
$index = 1;
$output .= "{$multi}## Record " . ($record_id + 1) . "\n";
foreach ($record as $key => $value) {
$output .= $index++ . ". __{$key}__: {$value}\n";
}
$output .= "\n";
}
$output .= "\n";
}
$this->output = $output;
return $this;
}