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

xtemplate: support extend #564

Closed
yiminghe opened this issue Feb 19, 2014 · 0 comments
Closed

xtemplate: support extend #564

yiminghe opened this issue Feb 19, 2014 · 0 comments
Milestone

Comments

@yiminghe
Copy link
Member

syntax

{{extend ("./layout")}}

Example

├── footer.xtpl
├── header.xtpl
├── index.xtpl
├── layout.xtpl
├── layout1.xtpl
└── sub
    └── header.xtpl

index.xtpl

{{extend ("./layout1")}}

{{#block ("head")}}
<!--index head block-->
<link type="text/css" href="test.css" rev="stylesheet" rel="stylesheet"  />
{{/block}}

{{#block ("body")}}
<!--index body block-->
<h2>{{title}}</h2>
{{/block}}

layout1.xtpl

<!doctype html>
<html>
<head>
<meta name="charset" content="utf-8" />
<title>{{title}}</title>
{{{block ("head")}}}
</head>
<body>
{{{include ("./header")}}}
{{{block ("body")}}}
{{{include ("./footer")}}}
</body>
</html>

render

res.render("index", {title: "xtpl engine!"})

output

<!doctype html>
<html>
<head>
<meta name="charset" content="utf-8" />
<title>xtpl engine!</title>

<!--index head block-->
<link type="text/css" href="test.css" rev="stylesheet" rel="stylesheet"  />

</head>
<body>
<h1>header</h1>
<h2>sub header</h2>

<!--index body block-->
<h2>xtpl engine!</h2>

<h1>footer</h1>

</body>
</html>
@yiminghe yiminghe added this to the 5.0.0 milestone Apr 24, 2014
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