Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TwigCodeCoverage

MageLens\TwigCodeCoverage\TemplateParser accepts the application's configured Twig\Environment. Pass a Twig\Source containing the original template code, logical name and file path.

$parser = new MageLens\TwigCodeCoverage\TemplateParser($twig);
$result = $parser->parse(new Twig\Source($code, $templateName, $path));

The result includes the path, a SHA-256 fingerprint of the original bytes and source-ordered units with a kind and a one-based starting line. Text contributes one unit per nonblank source line. A template can have multiple units on a line. Twig syntax errors propagate as Twig\Error\SyntaxError with the source context and error line.

The result also contains:

  • blocks for declarations, with a source-position ID, name, line, column, and owning block ID for nested declarations.
  • references for inheritance, includes, embeds, trait and macro imports, and block calls. Each reference records its kind, original syntax, tag or function form, position, owning block ID, and declared target. Literal targets are kept in order, _self identifies the current template, and computed targets are unresolved. Block calls also identify the block name when it is known.

Shopware resolves references when rendering. Namespaced references in the result keep the spelling from the source.

Run the parser fixtures with composer install followed by composer test.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages