0

I'm using the :php HAML filter that is supplied with haml-contrib to write blocks of php code inside a haml file.

this allows me to write:

!!! 5
%html
     %body
     -# HAML code ...
     :php
         // php code ...

I want to hightlight the php code in vim using this vim-tip. However, the default php syntax file that is supplied with my stock vim only highlights php code that is inside <?php ,?> tags.

How can I get around this?

Note that I can get the vim-tip to work, so highlighting the following:

!!! 5
%html
     %body
     -# HAML code ...
     :php
         <?php
              // php code ...
         ?>

does work! It just creates bad HAML output (double <?php ... ?> tags) and doesn't reflect the simplicity I want to achieve using HAML.

0

1 Answer 1

1

It's more along the lines that you need updated HAML syntax rules that allow vim to detect when you're going from haml->php.

Remember, there's no such thing as a "php script". There's only files which have php code blocks embedded in them, and those code blocks are delimited with <?php ... ?>. There's no way for vim's php rules to directly detect that you've broken into php mode, because you don't have the <?php to signal that.

2
  • yes, but my question is: 'How to tell vim that :php in a .haml file means that a php code block has started?'
    – romeovs
    Commented Apr 10, 2013 at 17:01
  • like I said... add the rule to the haml syntax rules. you can look at how the PHP highlighter can detect html/javascript contexts in php files for reference.
    – Marc B
    Commented Apr 10, 2013 at 17:03

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.