Ace can either highlight syntax for JSON or handlebar, but not at the same time.
I'm using ace editor with "handlebar" mode for a web ide.
editor.getSession().setMode('ace/mode/handlebar');
It works as intended. However, when ace is set to mode 'handlebar', no syntax displays for the json, so it looks really ugly and error detection is really difficult.
If I set the ace editor mode to
editor.getSession().setMode('ace/mode/json');
Ace editor displays errors due to the handlebar code syntax in the json.
For example, {{#each data.content.people}} is handlebar syntax, and so if ace editor is set to mode 'json', it will display an error at that line.
example json:
{
"menu": {
"id": "file",
"value": "File",
"types": [
{
"name": "NAMES",
"values": [
{{#each data.content.people}}
{
"name": {
"value": "{{{this}}}",
"synonyms": [
"{{{lowerCase this}}}"
]
}
}{{#unless @last}}, {{/unless}}
{{/each}}
]
}
],
"popup": {
"menuitem": [
{
"value": "New", "onclick": "CreateNewDoc()"
},
{
"value": "Open", "onclick": "OpenDoc()"
},
{
"value": "Close", "onclick": "CloseDoc()"
}
]
}
}
}
Is there a way for Ace editor to have syntax detection for both json and handlebar at the same time without having to create a custom mode?