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

Is there support for multi-level inheritance? #14

Open
dmoklaf opened this issue Apr 18, 2017 · 2 comments
Open

Is there support for multi-level inheritance? #14

dmoklaf opened this issue Apr 18, 2017 · 2 comments

Comments

@dmoklaf
Copy link

dmoklaf commented Apr 18, 2017

I am trying to use multi-level inheritance in Hero:

The master page skeleton for the whole website is "page.html":

<!DOCTYPE html>
<html lang="en">
...
<body>
	...
	PAGE
	<%@ content { %><% } %>
	...
</body>
</html>

For the admin part of the website it is refined into a second page skeleton "adminpage.html":

<%~ "page.html" %>
<%@ content { %>
	...
	ADMINPAGE
	<%@ admincontent { %><% } %>
<% } %>

And finally this is used in an "admintest.html" page:

<%: func AdminTest(w io.Writer) (int, error) %>
<%~ "adminpage.html" %>
<%@ admincontent { %>
ADMINTEST
<% } %>

But I can't make it work : the resulting test.html.go file has only the PAGE test marker, and no ADMINPAGE or ADMINTEST marker.

Is multiple-level inheritance supported?

  • If not that shall be indicated in the doc as it is a key requirement for large websites (and would be the only thing missing from hero to be just perfect :(
  • If yes shall I proceed differently?
@shiyanhui
Copy link
Owner

No yet.

Hero can't recognize nested block in parent-template for now. It seems that this feature is very important, so I'll add this feature later. Thanks!

@rohanthewiz
Copy link

rohanthewiz commented Apr 21, 2017

Hmm, why not just use partials. I was able to achieve admin content like this:

About Page

<%! import "bytes"; %>

<%: func PageAbout(buffer *bytes.Buffer, admin bool) %>
<%~ "layout.html" %>

<%@ header { %>
	<% if admin { %>
		<%+ "admin_menu.html" %>
	<% } %>
	<%+ "top_menu.html" %>
<% } %>

<%@ body { %>
	<p>
	Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusantium, assumenda commodi eaque esse illo nam nisi nostrum quaerat, quasi quis rerum ullam voluptate. Eos impedit maiores molestias nam nisi quisquam?
	Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto dolore eligendi inventore laudantium quaerat, quas. Accusamus commodi dolor eveniet in labore molestias neque nulla, omnis sed soluta tenetur ullam. Debitis.
	</p>
<% } %>

<%@ left_side { %>
	<span>Some arbitrary content</span>
<% } %>

Layout:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
</head>

<body>
<div id="banner">Banner and Logo goes here</div>
<%@ header { %>
<% } %>

<div id="main">
	<%@ body { %>
	<% } %>
</div>

<div id="left-side">
	<%@ left_side { %>
	<% } %>
</div>

<div id="right-side">
	<%@ right_side { %>
	<% } %>
</div>

<div id="footer">&copy;2017 GoNotes.net</div>

<%@ scripts { %>
<% } %>
</body>
</html>

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

No branches or pull requests

3 participants