Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine
MIT License
1.24k stars 214 forks source link

Should I be able to use a forward slash in an expression? #470

Closed foconnor-DS closed 2 years ago

foconnor-DS commented 2 years ago

I'm using handlebars to help write a generic data import tool. One of the test fields from the data file is:

Mailing State/Province

I'd like to refer to it, in an expression. I've tried: {{[Mailing State/Province]}} {{{[Mailing State/Province]}}} Both fail to find the string key in the Dictionary<string,dynamic> I pass in.

Should this be valid syntax? I thought brackets were supposed to escape the off limits literals

Whitespace ! " # % & ' ( ) * + , . / ; < = > @ [ \ ] ^ ` { | } ~

The bracket escape seems to work for the other no-go literals i've run into.

Thanks.

oformaniuk commented 2 years ago

Hello @foconnor-DS You are right, [] should escape the literals and is treated as a single string. If you can provide a test case it would be easier to find where the problem is.

foconnor-DS commented 2 years ago

Okay, I ran out of time this morning, but near as I can tell, all string literal notation is boken:

https://gist.github.com/foconnor-DS/7c991dff845e6ac1973e8534bb87c6b4

I wrote the code based on https://handlebarsjs.com/guide/expressions.html#literal-segments.

This test against the following notations: