[Vuejs]-SSR index.html compilation

0👍

Workaround to it is to pass html generation to function, so html file is replaced with

{{ range $el := index . "metaTags" }}
  {{$el|meta}}
  {{ end }}

and we register a function to create HTML

template.FuncMap{
            "meta": func(s api.Tag) template.HTML {
                return template.HTML("<meta " + s.Key + "=\"" + s.Name + "\"  " + s.Type + "=\"" + s.Content + "\" data-vue-router-controlled />")
            },
        }

Struct

type Tag struct {
    Key     string `json:"key"`
    Name    string `json:"name"`
    Type    string `json:"type"`
    Content string `json:"content"`
}

Leave a comment