goview icon indicating copy to clipboard operation
goview copied to clipboard

What file structure should I create to minimize duplication of html code?

Open LazarenkoA opened this issue 3 years ago • 2 comments

Hi. I have such a file structure, index.html the main one, css styles and scripts are connected in it image

the data that differ I have taken out in partials, I would like to index.html output {{template "ext" .}} or {{template "conf" .}} depending on the current page or get the parameter, is it possible to do this? Create a copy index.html , but with {{template "conf" .}} I would not like to because there can be a large number of pages

LazarenkoA avatar Apr 04 '22 17:04 LazarenkoA

image

LazarenkoA avatar Apr 04 '22 17:04 LazarenkoA

Why not use master layout file?

goview.Config{
    Root:      "views", //template root path
    Extension: ".tpl", //file extension
    Master:    "layouts/master", //master layout file
    Partials:  []string{"partials/head"}, //partial files
    Funcs: template.FuncMap{
        "sub": func(a, b int) int {
            return a - b
        },
        // more funcs
    },
    DisableCache: false, //if disable cache, auto reload template file for debug.
    Delims:       Delims{Left: "{{", Right: "}}"},
}

foolin avatar Apr 09 '22 09:04 foolin