TextMate Edit Bundle Snippet

174 views Asked by At

I want to update the HTML bundle so that the head snippet outputs <meta charset="utf-8"> instead of <meta http-equiv="Content-type" content="text/html; charset=utf-8"> if the doctype is HTML5. How?

This is what it looks like now in the Bundle Editor:

<head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8"${TM_XHTML}>
  <title>${1:${TM_FILENAME/((.+)\..*)?/(?2:$2:Page Title)/}}</title>
  $0
</head>
1

There are 1 answers

0
Jason Marcell On

Textmate allows you to interpolate shell code into snippets. The shell code is evaluated and placed inline. So you could write some Ruby (or some other code: maybe Perl or some funky combination of old-school sed, grep, awk, etc.) that can extract out the doctype. Then test on the result in an if-then block and echo whichever head you'd prefer.