curlz icon indicating copy to clipboard operation
curlz copied to clipboard

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

Open sassman opened this issue 2 years ago • 1 comments

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 avatar Feb 01 '23 23:02 sassman

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 :warning:
curlz/src/curlz/templ-lang/lexer.rs 0.00% 44 Missing :warning:
curlz/src/curlz/templ-lang/runtime.rs 0.00% 26 Missing :warning:
curlz/src/curlz/templ-lang/tokens.rs 0.00% 11 Missing :warning:
curlz/src/curlz/templ-lang/ast.rs 0.00% 9 Missing :warning:
curlz/src/curlz/templ-lang/ast_visitor.rs 0.00% 6 Missing :warning:
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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 06 '24 09:05 codecov[bot]