Skip to content

Instantly share code, notes, and snippets.

@quezo
Created July 11, 2016 18:33
Show Gist options
  • Save quezo/994678f74bac733198d651849402fc20 to your computer and use it in GitHub Desktop.
Save quezo/994678f74bac733198d651849402fc20 to your computer and use it in GitHub Desktop.
A simple example of how we use Emmet CodeMirror with Webpack/ES6
import * as emmet from 'emmet-codemirror';
import _ from 'lodash';
export const initEmmet = (CodeMirror) => {
// Initialize emmet Library by passing it a copy of
// CodeMirror library
emmet.setup(CodeMirror);
};
const emmetSupportedFileTypes = [
"html", "haml", "slim", "markdown", "jade",
"css", "scss", "postcss", "sass", "stylus", "less"
];
const enableEmmetOnFileType = (fileType) => {
return _.includes(emmetSupportedFileTypes, fileType);
};
export const configureEmmetForCMMode = (codeMirror, fileType) => {
if (enableEmmetOnFileType(fileType)) {
emmet.default(codeMirror);
} else {
emmet.dispose(codeMirror);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment