Handlebars.js - incorrect "Unexpected token" error

Answered

I'm using Handlebars.js in an ASP.NET MVC application. When I try to use the {{#if ...}} block helper to wrap the checked attribute of a checkbox or radio button, R# is throwing up an incorrect "unexpected token" error.

<input type="radio" {{#if isSelected}}checked="checked"{{/if}} />

The code compiles and works as expected.

Is there any way to avoid this error? Or at least make R# ignore the Handlebars templates?

Visual Studio 2017 15.9.7
R# 2018.3.3

2 comments
Official comment

Hi Richard!

I am afraid there is no way to avoid this error now.
To ignore these files by ReSharper you should change file extensions, if this is possibly.

Unfortunately, that's not an option. The templates are within a CSHTML file, and are being built dynamically based on the view-model.

0

Please sign in to leave a comment.