RainLab\Pages\Classes\Page::getPlaceholdersAttribute PHP Method

getPlaceholdersAttribute() public method

Parses the page placeholder {% put %} tags and extracts the placeholder values.
public getPlaceholdersAttribute ( ) : array
return array Returns an associative array of the placeholder names and values.
    public function getPlaceholdersAttribute()
    {
        if (!strlen($this->code)) {
            return [];
        }
        if ($placeholders = array_get($this->attributes, 'placeholders')) {
            return $placeholders;
        }
        $bodyNode = $this->getTwigNodeTree($this->code)->getNode('body')->getNode(0);
        if ($bodyNode instanceof \Cms\Twig\PutNode) {
            $bodyNode = [$bodyNode];
        }
        $result = [];
        foreach ($bodyNode as $node) {
            if (!$node instanceof \Cms\Twig\PutNode) {
                continue;
            }
            $bodyNode = $node->getNode('body');
            $result[$node->getAttribute('name')] = trim($bodyNode->getAttribute('data'));
        }
        $this->attributes['placeholders'] = $result;
        return $result;
    }