Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TemplateLiteral.php

function TemplateLiteral::setParts

Sets the array of the template parts (quasis and expressions)

Parameters

array Template parts:

Return value

$this

File

vendor/mck89/peast/lib/Peast/Syntax/Node/TemplateLiteral.php, line 118

Class

TemplateLiteral
A node that represents a template literal. For example: `this is a ${test()} template`

Namespace

Peast\Syntax\Node

Code

public function setParts($parts) {
    $this->assertArrayOf($parts, array(
        "Expression",
        "TemplateElement",
    ));
    $quasis = $expressions = array();
    foreach ($parts as $part) {
        if ($part instanceof TemplateElement) {
            $quasis[] = $part;
        }
        else {
            $expressions[] = $part;
        }
    }
    return $this->setQuasis($quasis)
        ->setExpressions($expressions);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal