Reputation: 538
I have a HTML file, and I’m using python code inside curly braces (web2py templates), something like
{{for i in range something:}}
{{=i.name}}
{{pass}}
inside the body of a file with a .html extension.
My question is, How can I change the colour of the code inside the {{}}
delimiters? The delimiters have a different colour with rainbow-delimiters and also I have auto-pair, but what I’d really like to have is a custom colour for the python code inside delimiters within the .html file.
Upvotes: 3
Views: 187
Reputation: 538
After a few months i have to say thanks to @sean perry for the hint, finally i found out what i needed, i'm not an emacs expert but here is my solution:
First downloaded multi-web-mode
then as the set up steps say added this to my init.el:
(require 'multi-web-mode)
(setq mweb-default-major-mode 'html-mode)
(setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
(js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
(css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
(setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
(multi-web-global-mode 1)
finally after css-mode added this line:
(python-mode "{{" "}}")
and now the python code between {{ }} in web2py's templates is correctly highlighted.
Upvotes: 0
Reputation: 3886
This is a common request. It is not easy to do in Emacs unfortunately. Look here for some options Multiple modes on Emacs Wiki. BTW, if you have never looked around it the Emacs Wiki has LOTS of useful info.
Upvotes: 2