Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to expand for attribute to htmlFor? #116

Open
sooqua opened this issue Sep 11, 2019 · 2 comments
Open

Option to expand for attribute to htmlFor? #116

sooqua opened this issue Sep 11, 2019 · 2 comments

Comments

@sooqua
Copy link

sooqua commented Sep 11, 2019

It's nice that there's an option to expand class as className, but how do I go about implementing the same for the for attribute in jsx?

@sooqua
Copy link
Author

sooqua commented Sep 11, 2019

Quick fix:

(defun +web-emmet-make-tag-a (tag-maker tag-info &optional content)
  "Extract tag info and pass them to tag-maker."
  (let* ((name      (pop tag-info))
         (has-body? (pop tag-info))
         (id        (pop tag-info))
         (classes   (pop tag-info))
         (props     (pop tag-info))
         (txt       (pop tag-info))
         (settings  (gethash name emmet-tag-settings-table))
         (self-closing?
          (and (not (or txt content))
               (or  (not has-body?)
                    (and settings (gethash "selfClosing" settings))))))
    (when (string= name "label")
      (let ((defaultAttr (gethash "defaultAttr" settings)))
        (remhash "for" defaultAttr)
        (remhash "htmlFor" defaultAttr)
        (if (derived-mode-p 'rjsx-mode)
            (puthash "htmlFor" "" defaultAttr)
          (puthash "for" "" defaultAttr))))
    (funcall tag-maker name has-body? id classes props txt settings
             (if content content
               (if (and emmet-leaf-function (not self-closing?))
                   (funcall emmet-leaf-function))))))
(advice-add #'emmet-make-tag :override #'+web-emmet-make-tag-a)

@sooqua
Copy link
Author

sooqua commented Sep 11, 2019

Or

(defun +web-emmet-make-tag-a (_ tag-info)
  (let ((name (car tag-info)))
    (when (string= name "label")
      (let ((defaultAttr (gethash "defaultAttr" (gethash name emmet-tag-settings-table))))
        (remhash "for" defaultAttr)
        (remhash "htmlFor" defaultAttr)
        (if (derived-mode-p 'rjsx-mode)
            (puthash "htmlFor" "" defaultAttr)
          (puthash "for" "" defaultAttr))))))
(advice-add #'emmet-make-tag :before #'+web-emmet-make-tag-a)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant