Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquid Mode for Codemirror2 #57

Open
alexkravets opened this issue Sep 17, 2011 · 6 comments
Open

Liquid Mode for Codemirror2 #57

alexkravets opened this issue Sep 17, 2011 · 6 comments

Comments

@alexkravets
Copy link

Hey guys,

is anyone working on Liquid mode for CodeMirror2?

Liquid templates are used in LocomotiveCMS and current branch uses CodeMirror 1 as main editor. I've integrated second version of CodeMirror and CoffeeScript support to LocomotiveCMS: https://github.com/alexkravets/engine - but there is no support for Liquid mode in CodeMirror 2 and now HTML mixed mode is used while editing Liquid templates and it doesn't highlight tags.

I wonder if there is anyone who may port Liquid mode for CM1 to CM2: https://github.com/tobi/liquid-editor/tree/master/public/codemirror/js

Thanks.

@marijnh
Copy link
Member

marijnh commented Sep 19, 2011

Using a simple overlay mode with the HTML mixed mode is probably the easiest way to handle this. See http://codemirror.net/demo/mustache.html for an example of using an overlay.

@alexkravets
Copy link
Author

Thanks. This might help a lot!

@kylefox
Copy link

kylefox commented Nov 11, 2011

I'm sure there's a much more elegant way of accomplishing this (not to mention, more features that could be added) ... but here's a very basic liquid overlay: https://gist.github.com/1356686

Just for anyone who hits this page after searching Google for "CodeMirror liquid parser", like I did :)

@marijnh
Copy link
Member

marijnh commented Nov 11, 2011

Thanks for linking that!

@hennk
Copy link

hennk commented May 11, 2012

Hi,

I just extracted the liquid mode we created for our template editor at https://github.com/axtro/codemirror_liquid_mode. It contains a pure liquid mode, and another overlay mode based on htmlmixed.

It also includes code to make the formatting module of CodeMirror2 compatible with the htmlmixedliquid mode, and another extension to comment/decomment liquid code.

You will see that the parser inserts some autocomplete information into the generated tokens. We use this information in our editor to provide intelligent autocompletion based on the type of the next expected token.

Cheers,

Henning

@joshco
Copy link

joshco commented Nov 15, 2015

This all looks helpful, but where I'm confused about is how to I actually use this?
Do I just drop @kylefox 's code, as-is, into my applications javascript files?
Do I need to set change my code that calls the

editor = CodeMirror.fromTextArea(....

same question for @hennk 's approach
FWIW, Im using codemirror in a Rails app to let my users edit their templates using Liquid and HAML or ERB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants