Share code between Shortcodes and Custom Templates.
Snippets are template abstractions enabling you to reuse the same markup and logic used to create Shortcodes in your Custom Layouts. Take for example the included Button Group shortcode used for creating a set of styled buttons, which we’ll look at in detail here. First the partial: <div class="btn-group{{ifeq.formactions"true"}}form-actions{{end}}{{with.class}}{{.}}{{end}}"> {{.body}} </div> Now the shortcode: {{$formactions:=.Get"formactions"}} {{$class:=.Get"class"}} {{$body:=.Inner}} {{partial"components/buttongroup.html"(dict"formactions"$formactions"class"$class"body"$body)}} Notice how the shortcode serves only to collect input and call the partial, which contains all markup and display logic.