Menu

Template your files with Goplater
📰

Template your files with Goplater

#golang#redditgolang#standard#course#markdown
Reading 0:00
15s threshold

Hey there fellow gophers,

About a year ago I started developing a templating cli app to help me with creating my READMEs and documentation.

Since I started to really get into go around that time, I of course chose its standard templating library for the job!

I have been using it mainly for including examples or assets in my markdown files:

+{{- $app := jsonDecode (readRaw "./package.json") -}} # +{{ upper (index $app "name") }} Version: +{{ index $app "version" }} +{{ read "./install.md" }}

A big step was implementing custom user-defined functions that can be imported and used without writing a single line of go, here an example:

{{ define "property(name, type, description)" }} ### {{ .name }} - **Type:** `{{ .type }}` - **Description:** {{ .description }} {{ end }} {{ call "property" "version" "string" "Release v1.2.3" }} {{ call "property" "license" "string" "Licensed under MIT" }}

Custom functions can of course ;) also be added by creating go function "modules" by using the underlying gplt-engine…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.