Skip to content

1.10.0

Compare
Choose a tag to compare
@JohnathonKoster JohnathonKoster released this 16 Oct 23:15
· 8 commits to master since this release
163130b

This release adds a few new helper methods:

  • toDocument() on DocumentParser simplifies the process of converting an existing DocumentParser to a Document instance
    • toDocument will resolve structures on the document by default. To prevent this, simply supply false when calling (i.e., toDocument(false))
  • parseTemplate on DocumentParser parses the input like the existing parse method, but will return the DocumentParser instance instead of a node array

New AttributeCompiler

The AttributeCompiler is a new compiler service that can be used to compile attributes/parameters on a parsed ComponentNode. The AttributeCompiler implementation will use the core Laravel compiler for content that contains interpolated values.

Usage:

<?php

use Stillat\BladeParser\Parser\DocumentParser;
use Stillat\BladeParser\Compiler\CompilerServices\AttributeCompiler;

$template = <<<'TEMPLATE'
<prefix:component
  parameter="content"
  :binding="$theVariable"
/>
TEMPLATE;

$params = (new DocumentParser)
        ->onlyParseComponents()
        ->registerCustomComponentTags(['prefix'])
        ->parseTemplate($template)
        ->toDocument()
        ->getComponents()
        ->first()
        ->parameters;

$compiler = new AttributeCompiler;
$result = $compiler->compile($params);

After compilation, $result would contain the following:

['parameter'=>'content','binding'=>$theVariable]