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.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...