Created
June 30, 2017 18:01
-
-
Save blaskovicz/981124737402a5407d110cf853977aaa to your computer and use it in GitHub Desktop.
Golang template features (nested variables, range over array, index into map, conditionals)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="levels"> | |
{{ $groups := .LevelGroups }} | |
{{ $groupedLevels := .Levels }} | |
{{ $completeLevels := .CompleteLevels }} | |
{{ if $groupedLevels }} | |
{{ range $group := $groups }} | |
<div class="intro"><h2>{{$group}}</h2></div> | |
{{ range index $groupedLevels $group }} | |
<a href="/level/{{.Number}}" class="{{if index $completeLevels .Number}}complete{{end}}"> | |
<span class="level">{{.Number}} </span> | |
{{.Title}} | |
<span class="mark-complete">¢</span> | |
</a> | |
{{end}} | |
<br /> | |
{{ end }} | |
{{ end }} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
💻 Edit or ⏯️ run this Gist on the www.CarlyZach.com code playground 💻