Ok, this is probably not the best solution because it is pretty invasive. But, it's all I could come up with so I will give it to you.
One thing we can do is basically manually do the highlighting ourselves. So we could easily do something like:
syn match quotedErubyBlock '"<%.\{-}%>"'
This will define a new highlighting section that matches "<% followed by any text, followed by %>". This should get us what we want, but the problem with this is that it will only affect strings that are not contained in any other syntax region. Clearly in your example this is going to show up in an htmlTag region, and so we need to get a bit more complicated. What I've come up with is the following:
autocmd BufReadPost *.html syn match quotedErubyBlock '"<%.\{-}%>"' contained
autocmd BufReadPost *.html syn region htmlTag start=+<[^/]+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,quotedErubyBlock,@htmlPreproc,@htmlArgCluster
autocmd BufReadPost *.html hi link quotedErubyBlock Constant
Ok, that's a lot to swallow. Let's go through it.
- The first line defines our new highlighting section
quotedErubyBlock and also specifies that it will be contained in some other region.
- The next line is the invasive part. I've stolen this line from vim's
html.vim file. Basically we are redefining what an htmlTag is. The only thing I changed is I added our quotedErubyBlock to the contains= list. This way vim can "see" our new highlighting section within an htmlTag block.
- This line just tells vim what color to highlight our new section with. I've put
Constant because I think that will give you what you are looking for, but feel free to change it to whatever works best for you.
As a last note, the autocmd BufReadPost *.html is an autocommand that will do our highlighting whenever a file is loaded with the extension html. I'm not very familiar with eruby, so you may need to change this if that is not the proper filetype.
See the vimwiki's page on creating your own syntax file for more information.
Hope this helps.
htmlTagsyntax definition includes two clusters (@htmlPreproc, and@htmlArgCluster). So you could do:syntax cluster htmlPreproc add=quotedErubyBlock(which makes sense in a way = the eruby part will be handled by pre-processor of sorts). Then you won't have to modify thehtmlTagdefinition. – muru Apr 21 '16 at 16:18~/.vim/after/syntax/eruby.viminstead ofautocmds. It's neater (and I suppose, more efficient, since not all HTML files need be eruby files, and you only need this when using theerubysyntax).