public function setPlaceholdersAttribute($value)
{
if (!is_array($value)) {
return;
}
// Prune any attempt at setting a placeholder that
// is not actually defined by this pages layout.
$placeholders = array_intersect_key($value, $this->listLayoutPlaceholders());
$result = '';
foreach ($placeholders as $code => $content) {
if (!strlen(trim($content))) {
continue;
}
$result .= '{% put ' . $code . ' %}' . PHP_EOL;
$result .= $content . PHP_EOL;
$result .= '{% endput %}' . PHP_EOL;
$result .= PHP_EOL;
}
$this->attributes['code'] = trim($result);
$this->attributes['placeholders'] = $placeholders;
}