-
I was looking for a way to render markdown files and I found that scriggo site extends a template and uses a macro declaration to render the markdown content. Is there another way to do it? Is it possible to directly convert a markdown file to html without extends a layout and use macros? |
Beta Was this translation helpful? Give feedback.
Answered by
gazerro
Dec 1, 2021
Replies: 1 comment
-
You can use a <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.html", opts)
if err != nil {
log.Fatal(err)
}
err = template.Run(os.Stdout, nil, nil)
if err != nil {
log.Fatal(err)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
akagusu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use a
show
statement in combination with anusing
statement:It is rendered as
This is the complete example: