Working with Embedded Languages

Learn how to work with embedded languages using an HTML fragment parser.

We will work to build an HTML fragment and position analyzer. Our parser will not be concerned with creating the association between HTML elements, nor will it extract the content or sections of the document between the elements. Instead, we will focus entirely on where HTML elements appear and what features they can have, such as parameters or attributes. The intended use case for this parser will be to help make decisions from the results of other parsers.

For example, let’s look at the following Blade template, which dynamically constructs an HTML tag pair from a variable:

Get hands-on with 1200+ tech skills courses.