Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine
MIT License
1.26k stars 217 forks source link

[Question] How to escape {{ }} ? #419

Closed StefH closed 3 years ago

StefH commented 3 years ago

I've this expression:

"{{Format {{Now}} \"yyyy-MM-dd\"}}",

Where {{Now}} is a helper which returns the current datetime. And Format is an helper which formats the DateTime as the specified format.

However, this fails:

Unhandled exception. HandlebarsDotNet.HandlebarsParserException: Reached unparseable token in expression: {Now}} "yyyy-MM-dd"}}

So my question is how to properly escape the {{ for the Now?

oformaniuk commented 3 years ago

Hello @StefH

Correct expression would look like this:

"{{Format (Now) 'yyyy-MM-dd'}}"

It's not possible to escape {{ }} inside of expression at this point.

StefH commented 3 years ago

Thanks !