Skip to content

feat(experimental:template-language): start an own template language #27

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sassman
Copy link
Member

@sassman sassman commented Feb 1, 2023

CAUTION! This is an experiment

The whole reason for this experiment is to get closer to the http plugin template syntax as linked in #5

There the vscode plugin has this concept of system variables that follow the syntax of a mix of expression and function e.g.

  • {{$randomInt min max}}: Returns a random integer between min (included) and max (excluded)
  • {{$dotenv [%]variableName}}: Returns the environment value stored in the .env file which exists in the same directory of your .http file.

Both examples show that $<ident> is similar to a function name and then a variable argument list is passed without any braces like ().

This experiment focuses on the ability to register functions for this very system variable syntax at compile time in an extensible fashion.

done so far:

  • lexing and parsing of very basic templates with an expression {{ var }}
  • basic runtime to interpret the AST
  • some tests added
  • design of a Visitor pattern for the AST

yet open

  • tests for unhappy path are to less
  • runtime is very incomplete yet, SysVar hooked functions are missing e.g. hello {{ $processEnv HOME }}

@sassman sassman force-pushed the feat/x/custom-templ-language branch 3 times, most recently from 696a6a9 to dd9a0ae Compare February 1, 2023 23:43
@sassman sassman force-pushed the feat/x/custom-templ-language branch 3 times, most recently from 9a825cd to fa1a43d Compare February 10, 2023 16:37
@sassman sassman force-pushed the feat/x/custom-templ-language branch from 94eedd2 to 179290f Compare February 27, 2023 19:42
@sassman sassman added the experiment experiemental feature label Feb 28, 2023
@sassman sassman force-pushed the feat/x/custom-templ-language branch from 2e82b49 to 4f1ca62 Compare February 28, 2023 00:31
The whole reason for this experiment is to get closer to the http plugin template syntax as linked in #5
There the vscode plugin [has this concept of system variables](https://marketplace.visualstudio.com/items?itemName=humao.rest-client#system-variables) that follow the syntax of a mix of expression and function e.g.

- {{$randomInt min max}}: Returns a random integer between min (included) and max (excluded)
- {{$dotenv [%]variableName}}: Returns the environment value stored in the .env file which exists in the same directory of your .http file.

Both examples show that `$<ident>` is similar to a function name and then a variable argument list is passed without any braces like `()`.

This experiment focuses on the ability to register functions for this very system variable syntax at compile time in an extensible fashion.

done so far:
- lexing and parsing of very basic templates with an expression `{{ var }}`
- basic runtime to interpret the AST
- some tests added
- design of a Visitor pattern for the AST

yet open
- [ ] tests for unhappy path are to less
- [ ] runtime is very incomplete yet, `SysVar` hooked functions are missing e.g. `hello {{ $processEnv HOME }}`
@sassman sassman force-pushed the feat/x/custom-templ-language branch from deff5fc to e8638a9 Compare February 28, 2023 00:48
Copy link

codecov bot commented May 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 153 lines in your changes missing coverage. Please review.

Project coverage is 64.23%. Comparing base (1d18d4a) to head (8c69da2).

Files with missing lines Patch % Lines
curlz/src/curlz/templ-lang/parser.rs 0.00% 57 Missing ⚠️
curlz/src/curlz/templ-lang/lexer.rs 0.00% 44 Missing ⚠️
curlz/src/curlz/templ-lang/runtime.rs 0.00% 26 Missing ⚠️
curlz/src/curlz/templ-lang/tokens.rs 0.00% 11 Missing ⚠️
curlz/src/curlz/templ-lang/ast.rs 0.00% 9 Missing ⚠️
curlz/src/curlz/templ-lang/ast_visitor.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #27       +/-   ##
===========================================
- Coverage   74.50%   64.23%   -10.27%     
===========================================
  Files          37       43        +6     
  Lines         957     1110      +153     
===========================================
  Hits          713      713               
- Misses        244      397      +153     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experiment experiemental feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant