On 12 Jul 2016, at 22:37, Rasmus Malver wrote:
Since templates were discontinued I've been using this AppleScript tomake a quick HTML doc:
I suggest you change the command to a snippet with your desired boilerplate.
In this snippet you can use backticks to execute commands and then use TM_MATE to set the language of the current document, for example make the snippet like this:
<!DOCTYPE html>`"$TM_MATE" &>/dev/null -t text.html.php &`
<html lang="da">
…
When inserted, it should change document type to text.html.php
.
Another more declarative approach is via the PHP grammar’s first line match, though as your first line is currently matched by the HTML grammar, you need to make two changes:
Go to Bundles → HTML → Language Grammars → HTML and clear the First Line Match text field.
Go to Bundles → PHP → Language Grammars → PHP and change the First Line Match to this:
^#!.*(?<!-)php[0-9]{0,1}\b|<\?php|<!DOCTYPE html>
Now when the first line of a document contains <!DOCTYPE html>
TextMate will change type to PHP, this inclundes inserting your HTML boilerplate in a new untitled document.
[…] The problem is rather unusual. It appears that System Events isreversing the order of the commands.
It was likely caused by 26e66b8.
This change was made to fix another issue, it won’t be the last change related to synchronous command execution, but I am not sure TextMate should guarantee anything about the order in which things are done when running a command which produce output and send key strokes to TextMate (while running).
So I hope one of the two approaches suggested above will be acceptable solutions.