Skip to content

Render markdown files #924

Answered by gazerro
akagusu asked this question in Q&A
Discussion options

You must be logged in to vote

You can use a show statement in combination with an using statement:

<html>
<body>
{% show itea; using markdown %}
  # title
{% end %}
</body>
</html>

It is rendered as

<html>
<body>
<h1>title</h1>
</body>
</html>

This is the complete example:

package main

import (
	"io"
	"log"
	"os"

	"github.com/open2b/scriggo"
	"github.com/yuin/goldmark"
)

func main() {
	fsys := scriggo.Files{
		"index.html": []byte(`<html><body>{% show itea; using markdown %}# title{% end %}</body></html>`),
	}
	md := goldmark.New()
	opts := &scriggo.BuildOptions{
		MarkdownConverter: func(src []byte, out io.Writer) error {
			return md.Convert(src, out)
		},
	}
	template, err := scriggo.BuildTemplate(fsys, "index.h…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by akagusu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants