jhartwell / haml-rs

A pure Rust implementation of the Haml template language
MIT License
59 stars 3 forks source link

Add variable support #6

Open jhartwell opened 6 years ago

jhartwell commented 6 years ago

In order to be useful for future projects I want to work on as well as just keeping up with standard implementation variables need to be supported.

jhartwell commented 6 years ago

Need to better understand what would be wanted. The way I see it is that there are three ways to go:

1.) Allow for embedded Rust like the reference Haml allows for embedded Ruby 2.) Allow for embedded Ruby 3.) Cripple variable support and just support a basic hashmap where you can use variables but no expressions are allowed

The first two options are going to be much more work but will provide a better experience. I have looked into embedding Rust and use macros of some sort to allow access to current variables so nothing needs to be passed in but due to the hygienic nature of macros we won't be able to get at the original variables. There are libraries for generating Rust AST though, so that work wouldn't need to be done.

If we use crippled variables and just require a hashmap (or some sort of similar structure) is passed in and a straight replacement is done then it would mean that we would get variable support but at the cost of flexibility in the templates.