Skip to content

Instantly share code, notes, and snippets.

@whitlockjc
Last active December 21, 2015 01:19
Show Gist options
  • Save whitlockjc/6226791 to your computer and use it in GitHub Desktop.
Save whitlockjc/6226791 to your computer and use it in GitHub Desktop.
Use mmm-mode to enable EJS Template highlighting in html-mode
;; ...
;; Use mmm-mode to enable EJS (http://embeddedjs.com) Template highlighting in html-mode
;; Turn on mmm-mode
(require 'mmm-mode)
(setq mmm-global-mode 'maybe)
;; mmm-mode class for EJS Templates
(mmm-add-classes
'(
(html-ejs :submode js-mode :front "<%[#=]?" :back "-?%>"
:match-face (("<%#" . mmm-comment-submode-face)
("<%=" . mmm-output-submode-face)
("<%" . mmm-code-submode-face))
:insert ((?% ejs-code nil @ "<%" @ " " _ " " @ "%>" @)
(?# ejs-comment nil @ "<%#" @ " " _ " " @ "%>" @)
(?= ejs-expression nil @ "<%=" @ " " _ " " @ "%>" @))
)))
;;; Add html-js, embedded-css and html-ejs to html-mode
(mmm-add-mode-ext-class 'html-mode nil 'html-js)
(mmm-add-mode-ext-class 'html-mode nil 'html-css)
(mmm-add-mode-ext-class 'html-mode nil 'html-ejs)
;; ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment