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

using different Layout #1368

Open
ElhamAfshar opened this issue Sep 28, 2019 · 2 comments

Comments

@ElhamAfshar
Copy link

commented Sep 28, 2019

I need to use different Layout in my project

@ElhamAfshar

This comment has been minimized.

Copy link
Author

commented Sep 28, 2019

how can I use two different Layout ?
app.RegisterView(iris.HTML("web/view", ".html").Layout("layout.html"))

@kataras

This comment has been minimized.

Copy link
Owner

commented Oct 8, 2019

Layout is single per view. You can change the default layout defined on your iris.HTML(...).Layout(...) from the handler itself, through context.ViewLayout("other_layout.html") method.

iris/context/context.go

Lines 717 to 728 in c8e73f4

// ViewLayout sets the "layout" option if and when .View
// is being called afterwards, in the same request.
// Useful when need to set or/and change a layout based on the previous handlers in the chain.
//
// Note that the 'layoutTmplFile' argument can be set to iris.NoLayout || view.NoLayout
// to disable the layout for a specific view render action,
// it disables the engine's configuration's layout property.
//
// Look .ViewData and .View too.
//
// Example: https://github.com/kataras/iris/tree/master/_examples/view/context-view-data/
ViewLayout(layoutTmplFile string)

@kataras kataras added the question label Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.