-
The template string is fed to the parser.
-
The parser first determines the type of template string, which is called tokenizing. Let's consider three types of tokens – if tags, for tags, and template variables. In this example, a token of type template variable is generated (if the template string contains a static literal, it is written to the HTML output without any changes).
-
Then the template string is parsed into a static literal, Welcome, and a template variable {{name}}.
-
The outputs of the parser (from steps 2 and 3) are passed to the HTML generator.
-
Data from a data source is passed as context by the template engine to the generator.
-
The parsed token and strings (from steps 2 and 3) are combined with the context data (from step 5) to produce the result string, which is written to the output HTML file.
cargo run
<h2> Hello </h2>
<p> My name is {{name}} </p> or <p> I live in {{city}} </p>
Expected output: My name is Ujjawal I live in NewDelhi
- Implement ForTag
- Implement IfTag
- Add support for two variables on a single line html