Emacs go-template-mode

986 views
Skip to first unread message

Patrick Higgins

unread,
Jan 21, 2012, 4:38:25 PM1/21/12
to golang-nuts
I have created a major mode for editing files written in the template
language defined by the "template" package. It provides syntax
highlighting only. It will highlight HTML tags and template actions,
comments, strings, built-ins, and variables.

A current bug is that it highlights strings in the HTML as well as
inside template actions, and that means that template actions inside
HTML attributes are not highlighted (the entire attribute string is
highlighted as a single entity).

I also added an autoload entry for files with a ".gotmpl" extension.
Is there a standard extension for template files that should be used
instead?

I have put a version of the code up at https://gist.github.com/1654113
for review.

Right now it uses a lot of the code from go-mode.el, though I thought
it might be fun to use Semantic to write a real parser for it.

I propose adding this to the misc/emacs directory. Feedback?

Mostafa Hajizadeh

unread,
Jan 23, 2012, 1:41:59 PM1/23/12
to golan...@googlegroups.com
Very nice idea. Great for Emacs users like me.

But I guess the common template ext is .tmpl. At least this is what I've seen in codes from The Authors. :)

Patrick Higgins

unread,
Jan 25, 2012, 1:19:43 PM1/25/12
to golang-nuts
If .tmpl is the common extension, then I should probably leave the
auto-mode-list entry out and let users decide which extensions they
wish to associate with go-template-mode.

I guess I must have seen that extension used somewhere because it was
the one I was using myself before I wrote this mode! :)
Reply all
Reply to author
Forward
0 new messages