微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 胡子部分和代码重用

在周末开始的项目中,我得到了胡子的挂起.

我正在使用PHP实现.我有,但是几个查询,因为我不习惯这个系统.

如何处理模板继承或重用?
我知道偏偏,但我应该如何使用它们?我在做这样的事情,包括

top.mustache:

<!DOCTYPE html>
<html lang='es'>
<head>
    <Meta charset=utf-8" />
    <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" />
</head>
<body>
     <header><h1><a href="/">Top</a></h1>
     </header>
     <section>

bottom.mustache:

</section>
        <footer><a href="http://potajecreativo.com/">potaje</a></footer>
</body>
</html>

并且呈现此模板的视图:

{{>top}}
<form action="/album/" method="post">
    <p><label for="name">Name</label> <input type="text" name="name" value=""/></p>
    <p><label for="description">Description</label> <textarea name="description" rows="8" cols="40"></textarea></p>
    <p><input type="submit" value="Save" /></p>
</form>
{{>bottom }}

这是正确的做法吗?

ynkr的答案对于旧版本是正确的,但是我刚升级到2.4.1版,如果您使用的是文件系统加载器,那么您的方法应该可以工作.

详见https://github.com/bobthecow/mustache.php/wiki/Template-Loading#partials-loading.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐