ma11hew28
ma11hew28

Reputation: 126477

TextMate Edit Bundle Snippet

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>

Upvotes: 0

Views: 165

Answers (1)

Jason Marcell
Jason Marcell

Reputation: 2835

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.

Upvotes: 1

Related Questions