Skip to content

Low Level Templating Language (LLTL) #4

Closed
@Nercury

Description

@Nercury

Overview

The most efficient way to present template is to have it in known memory location from which template bytes can be streamed directly to the output. If the template has some executable logic, the chunks around this logic can still be presented directly, while the executable bits can be efficiently interpreted.

In LLTL all the fancy template features should be eliminated: template hierarchy resolved, additional resource loading not necessary, no extensions necessary (pre-processed).

The LLTL file itself should be enough to output the template, if all the necessary parameters are provided.

Implementation

The Twig in PHP is using AST to print PHP output directly. This is obviously ill-suited for Rust. Instead, the idea is to proceed as follows:

  1. Use the AST to construct STR (simple template representation) of the same AST. In this step we can process all the work from extensions and avoid loading them at the runtime. In case out final STR depends on the extensions, we can simply hash the extensions at the generation and use this hash to validate that STR is still valid for them.

  2. Use STR to output LLTL. LLTL can be thought as a cache file at this point. However, some basic interpreter would still be needed to run it, so, "low level template language" is more accurate.

Bonus

Later, it will be possible to do cool stuff like:

  • Generating LLR from another templating language
  • Compiling LLR directly to rust for production
  • Optimising LLR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions