From 437cd920044185b956d6ff6b8e9f4abbc1744bbd Mon Sep 17 00:00:00 2001 From: Conrad Decker Date: Thu, 17 Jul 2014 09:40:35 -0400 Subject: [PATCH] Changed 'parenthesis' setting to 'attribute_style' setting to allow for choice between 'hash' and 'html' Updated output to correctly display html-style attributes or hash-style attributes. 'attribute_style' setting defaults to hash but can be updated by the user to use html style attributes --- autoload/emmet.vim | 2 +- autoload/emmet/lang/haml.vim | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/autoload/emmet.vim b/autoload/emmet.vim index 6326f86..03fb698 100644 --- a/autoload/emmet.vim +++ b/autoload/emmet.vim @@ -1671,7 +1671,7 @@ let s:emmet_settings = { \ ."\t%body\n" \ ."\t\t${child}|\n", \ }, -\ 'parentheses': '{}', +\ 'attribute_style': 'hash', \ }, \ 'slim': { \ 'indentation': ' ', diff --git a/autoload/emmet/lang/haml.vim b/autoload/emmet/lang/haml.vim index 36e9d27..f0c5e88 100644 --- a/autoload/emmet/lang/haml.vim +++ b/autoload/emmet/lang/haml.vim @@ -15,7 +15,7 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite let itemno = a:itemno let indent = emmet#getIndentation(type) let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) - let parentheses = emmet#getResource('haml', 'parentheses', '()') + let attribute_style = emmet#getResource('haml', 'attribute_style', 'hash') let str = "" let comment_indent = '' @@ -33,7 +33,11 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite endif let Val = current.attr[attr] if type(Val) == 2 && Val == function('emmet#types#true') - let tmp .= ' :' . attr . ' => true' + if attribute_style == 'hash' + let tmp .= ' :' . attr . ' => true' + elseif attribute_style == 'html' + let tmp .= attr . '=true' + end else if dollar_expr while Val =~ '\$\([^#{]\|$\)' @@ -47,14 +51,28 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite elseif attr == 'class' && len(valtmp) > 0 let str .= '.' . substitute(Val, ' ', '.', 'g') else - if len(tmp) > 0 | let tmp .= ',' | endif + if len(tmp) > 0 + if attribute_style == 'hash' + let tmp .= ',' + elseif attribute_style == 'html' + let tmp .= ' ' + endif + endif let Val = substitute(Val, '\${cursor}', '', '') - let tmp .= ' :' . attr . ' => "' . Val . '"' + if attribute_style == 'hash' + let tmp .= ' :' . attr . ' => "' . Val . '"' + elseif attribute_style == 'html' + let tmp .= attr . '="' . Val . '"' + end endif endif endfor if len(tmp) - let str .= parentheses[0] . tmp . ' '. parentheses[1] + if attribute_style == 'hash' + let str .= '{' . tmp . ' }' + elseif attribute_style == 'html' + let str .= '(' . tmp . ')' + end endif if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0 let str .= "/"