Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LazarenkoA opened this issue Apr 4, 2022 · 2 comments

Comments

@LazarenkoA
Copy link

LazarenkoA commented Apr 4, 2022

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
Copy link
Author

image

@foolin
Copy link
Owner

foolin commented Apr 9, 2022

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: "}}"},
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants