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

need an other "yield" #57

Open
takkuumi opened this issue Dec 31, 2015 · 0 comments
Open

need an other "yield" #57

takkuumi opened this issue Dec 31, 2015 · 0 comments

Comments

@takkuumi
Copy link

my english is poor,sorry!
I just want to do this,in layout

<html>
....
{{yield}}
.....

{{res}}
<html>

now,I have a index file named index.html.in the same dir,i have an other file name index.html.res.
I want the index.html into the yield,and the index.html.res to the {{res}}

this is the dir like.

-----view
----------layout
---------------default.tmpl
----------xxx_dir
---------------xxx.html
---------------xxx.html.res
-----index.html
-----index.html.res

every res file content is different.How to do it?

I try to do it with Funcs,but i cant get the .res file path.

engine.Use(render.Renderer(render.Options{
        // Specify what path to load the templates from.
        Directory: conf.AppDir.View,
        // Specify a layout template. Layouts can call {{ yield }} to render the current template.
        Layout: "layout/default",
        // Specify extensions to load for templates.
        Extensions: []string{".tmpl", ".html"},
        // Specify helper function maps for templates to access.
        Funcs: []template.FuncMap{{
            "res":func(args ...interface{}) template.HTML {
                // here i cant get the .res path
                return template.HTML(s)
            },
        }},
        // Sets delimiters to the specified strings.
        Delims: render.Delims{"{{", "}}"},
        // Sets encoding for json and html content-types. Default is "UTF-8".
        Charset: "UTF-8",
        // Output human readable JSON
        IndentJSON: true,
    }))
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

1 participant