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\NodeCode
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);
}