Skip to content

need an other "yield" #57

@takkuumi

Description

@takkuumi

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,
    }))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions