Sublime Text/Atom Hugo Snippets

Hi guys!
No idea what took me so long to write those… Life changer!

Snippet Tab Trigger Output
Curlies x {{ }}
Dot dot {{ . }}
If if {{ if }} {{ end }}
If/Else ife {{ if }} {{ else }} {{ end }}
With with {{ with }} {{ end }}
With/Else withe {{ with }} {{ else }} {{ end }}
Range range {{ range }} {{ end }}
Partial partial {{ partial "" . }}
Block block {{ block "main" . }} {{ end }}
Block define define {{ define "block" }} {{ end }}

PackageControll PR is pending, in the mean time you can just drop them anywhere you want in /Users/whoever/Library/Application Support/Sublime Text 3/Packages

Tab away!

16 Likes

Nice. There is also else if.

Yes will add it!

They’ve been ported on Atom by @holehan.

2 Likes

awesome :grinning:

Also: What is the easiest way of importing these snippets …?

Package Control is coming (PR approved, but they don’t merge fast) in the mean time, you can just drop the files in there:

/Users/thatUser/Library/Application Support/Sublime Text 3/Packages/User/

For Atom, no idea.

2 Likes

How about adding comments?

{{/* */}}

I am using them quite a lot in my templates for notes about “how” and “why” and “what happens here”, because HTML comments are basically garbage in the final website :slight_smile: I see a lot of themes out there that use html comment tags but they are printed in the resulting html which is more or less useless baggage. in my humble opinion.

Yes I started using those, only a matter of days until I add a comment snippet.

PR welcome if can!

I did a PR.

(please note that’s basically my first PR ever I think, so bear with me if it’s garbage :))

Ah ah, first time I got to review one on my own repo :wink:

I did the atom one too while I was at it :smiley: it’s kind of addictive.

3 Likes

And another port, this time on VS Code:

2 Likes

Thank you for the VS Code snippets! I’ve been looking everywhere for something like this!

I just added .Scratch options to your repo as well. I also propose shortening “partial” to something like “xpar” since “partial” is being used by gohtml and tabbing doesnt seamlessly work

I just merged your changes. Please open an issue for the “partial” tab trigger so it can be tracked in the repo. Thanks!