SNYDERHAUS
SNYDERHAUS

Reputation: 451

Ace Editor - Remove error for specific syntax

I'm trying to make ace editor not count the following as "improper syntax" and be used for templating. Currently, I haven't been able to find anything similar that helps me work with ace and edit this. The closest I've found is Ace editor: customizing syntax error gutter which didn't really point me in a direction?

I want it so ace doesn't interpret:

var derp = %{ (whatever can go in here) }%;

both %{ and %{ respectively as an error.

Upvotes: 2

Views: 863

Answers (1)

a user
a user

Reputation: 24104

Ace uses jshint for syntax checking which is not very extensible. If you do not have a better syntax checker, you can try hooking into https://github.com/ajaxorg/ace/blob/v1.1.8/lib/ace/mode/javascript_worker.js#L118 and replace %{ ... }% blocks with expression/* ... */ like

value.replace(/%\{([^}]|}[^%])*}%/g, "window/*$1*/")

the expression is needed to keep js valid and comment to keep lines

Upvotes: 4

Related Questions