fb55/htmlparser2

feature: ignore PHP tags inside html tags

arnoson opened this issue · 1 comments

Thanks for this great parser! I use it to implement syntactic sugar for PHP-based templating.

I guess this parser is not ment to parse PHP, but so far everything works, except for PHP tags inside a tag:

<div <?= attributes([ 'class' => 'test']) ?>>
</div>

which results in

{
  "nodeName": "div",
  "tagName": "div",
  "attrs": [
    {
      "name": "<?",
      "value": "attributes(["
    },
    {
      "name": "'class'",
      "value": ""
    }
  ],
  "childNodes": [
    {
      "nodeName": "#text",
      "value": " 'test']) ?>>",
    }
  ],
}

Is there some way to simply ignore those PHP tags? Otherwise I might have to mask them before parsing.

Nevermind, I realised that it in my situation it makes more sense to write my own very basic parser, as I don't use much features of this package.