Skip to content

Instantly share code, notes, and snippets.

@HamedFathi
Forked from LucGranato/index.html
Created December 2, 2021 22:57
Show Gist options
  • Save HamedFathi/388016d65f7809de0d5a05cc45fa0911 to your computer and use it in GitHub Desktop.
Save HamedFathi/388016d65f7809de0d5a05cc45fa0911 to your computer and use it in GitHub Desktop.
Monaco Editor Liquid Language
<div id="container" style="height:100%;"></div>
monaco.languages.register({ id: 'liquid' });
monaco.languages.registerCompletionItemProvider('liquid', {
provideCompletionItems: () => {
var autocompleteProviderItems = [];
var keywords = ['assign', 'capture', 'endcapture', 'increment', 'decrement',
'if', 'else', 'elsif', 'endif', 'for', 'endfor', 'break',
'continue', 'limit', 'offset', 'range', 'reversed', 'cols',
'case', 'endcase', 'when', 'block', 'endblock', 'true', 'false',
'in', 'unless', 'endunless', 'cycle', 'tablerow', 'endtablerow',
'contains', 'startswith', 'endswith', 'comment', 'endcomment',
'raw', 'endraw', 'editable', 'endentitylist', 'endentityview', 'endinclude',
'endmarker', 'entitylist', 'entityview', 'forloop', 'image', 'include',
'marker', 'outputcache', 'plugin', 'style', 'text', 'widget',
'abs', 'append', 'at_least', 'at_most', 'capitalize', 'ceil', 'compact',
'concat', 'date', 'default', 'divided_by', 'downcase', 'escape',
'escape_once', 'first', 'floor', 'join', 'last', 'lstrip', 'map',
'minus', 'modulo', 'newline_to_br', 'plus', 'prepend', 'remove',
'remove_first', 'replace', 'replace_first', 'reverse', 'round',
'rstrip', 'size', 'slice', 'sort', 'sort_natural', 'split', 'strip',
'strip_html', 'strip_newlines', 'times', 'truncate', 'truncatewords',
'uniq', 'upcase', 'url_decode', 'url_encode'];
for (var i = 0; i < keywords.length; i++) {
autocompleteProviderItems.push({ 'label': keywords[i], kind: monaco.languages.CompletionItemKind.Keyword });
}
return {suggestions: autocompleteProviderItems};
}
});
monaco.editor.create(document.getElementById("container"), {
language: "liquid"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment