Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low Level Templating Language (LLTL) #4

Closed
Nercury opened this issue Aug 15, 2015 · 1 comment
Closed

Low Level Templating Language (LLTL) #4

Nercury opened this issue Aug 15, 2015 · 1 comment

Comments

@Nercury
Copy link
Owner

Nercury commented Aug 15, 2015

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
@Nercury
Copy link
Owner Author

Nercury commented Sep 16, 2015

Currently working on this in https://github.com/Nercury/little-rs project.

@Nercury Nercury closed this as completed Oct 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant