syn region rubyCurlyBlock start="{" end="}" contains=@hamlRubyTop contained
syn cluster hamlRubyTop add=rubyCurlyBlock
syn cluster hamlComponent contains=hamlAttributes,hamlAttributesHash,hamlClassChar,hamlIdChar,hamlObject,hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable
syn cluster hamlEmbeddedRuby contains=hamlAttributesHash,hamlObject,hamlRuby,hamlRubyFilter
syn cluster hamlTop contains=hamlBegin,hamlPlainFilter,hamlRubyFilter,hamlSassFilter,hamlComment,hamlHtmlComment
syn match hamlBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=hamlTag,hamlClassChar,hamlIdChar,hamlRuby,hamlPlainChar,hamlInterpolatable
syn match hamlTag "%\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@hamlComponent
syn region hamlAttributes matchgroup=hamlAttributesDelimiter start="(" end=")" contained contains=htmlArg,hamlAttributeString,hamlAttributeVariable,htmlEvent,htmlCssDefinition nextgroup=@hamlComponent
syn region hamlAttributesHash matchgroup=hamlAttributesDelimiter start="{" end="}" contained contains=@hamlRubyTop nextgroup=@hamlComponent
syn region hamlObject matchgroup=hamlObjectDelimiter start="\[" end="\]" contained contains=@hamlRubyTop nextgroup=@hamlComponent
syn match hamlDespacer "[<>]" contained nextgroup=hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable
syn match hamlSelfCloser "/" contained
syn match hamlClassChar "\." contained nextgroup=hamlClass
syn match hamlIdChar "#{\@!" contained nextgroup=hamlId
syn match hamlClass "\%(\w\|-\)\+" contained nextgroup=@hamlComponent
syn match hamlId "\%(\w\|-\)\+" contained nextgroup=@hamlComponent
syn region hamlDocType start="^\s*!!!" end="$"
syn region hamlRuby matchgroup=hamlRubyOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@hamlRubyTop keepend
syn region hamlRuby matchgroup=hamlRubyChar start="-" skip=",\s*$" end="$" contained contains=@hamlRubyTop keepend
syn match hamlPlainChar "\\" contained
syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="!\===\|!=\@!" end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape,@hamlHtmlTop
syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="&==\|&=\@!" end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape
syn region hamlInterpolation matchgroup=hamlInterpolationDelimiter start="#{" end="}" contains=@hamlRubyTop containedin=javascriptStringS,javascriptStringD
syn match hamlInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)"
syn region hamlErbInterpolation matchgroup=hamlInterpolationDelimiter start="<%[=-]\=" end="-\=%>" contained contains=@hamlRubyTop
syn region hamlAttributeString start=+\%(=\s*\)\@<='+ skip=+\%(\\\\\)*\\'+ end=+'+ contains=hamlInterpolation,hamlInterpolationEscape
syn region hamlAttributeString start=+\%(=\s*\)\@<="+ skip=+\%(\\\\\)*\\"+ end=+"+ contains=hamlInterpolation,hamlInterpolationEscape
syn match hamlAttributeVariable "\%(=\s*\)\@<=\%(@@\=\|\$\)\=\w\+" contained
syn match hamlHelper "\<action_view?\|\<block_is_haml?\|\<is_haml?\|\.\@<!\<flatten" contained containedin=@hamlEmbeddedRuby,@hamlRubyTop
syn cluster hamlHtmlTop contains=@htmlTop,htmlBold,htmlItalic,htmlUnderline
syn region hamlPlainFilter matchgroup=hamlFilter start="^\z(\s*\):\%(plain\|preserve\|redcloth\|textile\|markdown\|maruku\)\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlHtmlTop,hamlInterpolation
syn region hamlEscapedFilter matchgroup=hamlFilter start="^\z(\s*\):\%(escaped\|cdata\)\s*$" end="^\%(\z1 \| *$\)\@!" contains=hamlInterpolation
syn region hamlErbFilter matchgroup=hamlFilter start="^\z(\s*\):erb\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlHtmlTop,hamlErbInterpolation
syn region hamlRubyFilter matchgroup=hamlFilter start="^\z(\s*\):ruby\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlRubyTop
syn region hamlJavascriptFilter matchgroup=hamlFilter start="^\z(\s*\):javascript\s*$" end="^\%(\z1 \| *$\)\@!" contains=@htmlJavaScript,hamlInterpolation keepend
syn region hamlCSSFilter matchgroup=hamlFilter start="^\z(\s*\):css\s*$" end="^\%(\z1 \| *$\)\@!" contains=@htmlCss,hamlInterpolation keepend
syn region hamlSassFilter matchgroup=hamlFilter start="^\z(\s*\):sass\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlSassTop
syn region hamlJavascriptBlock start="^\z(\s*\)%script" nextgroup=@hamlComponent,hamlError end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,@htmlJavaScript keepend
syn region hamlCssBlock start="^\z(\s*\)%style" nextgroup=@hamlComponent,hamlError end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,@htmlCss keepend
syn match hamlError "\$" contained
syn region hamlComment start="^\z(\s*\)-#" end="^\%(\z1 \| *$\)\@!" contains=rubyTodo
syn region hamlHtmlComment start="^\z(\s*\)/" end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,rubyTodo
syn match hamlIEConditional "\%(^\s*/\)\@<=\[if\>[^]]*]" contained containedin=hamlHtmlComment