我正在爲我在週末開始的一個項目收集鬍子。小鬍子部分和代碼重用
我正在使用PHP實現。不過,由於我不習慣這個系統,所以我有一些問題。
如何處理模板的繼承或重用? 我知道partials,但我應該如何使用它們?我在做這樣的事情,阿拉包括:
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 }}
這是正確的做法嗎?
我假設你在你的例子中使用了Cake框架,儘管在問題或你的答案中沒有提到這個。你可能想澄清一下,在你的答案中,讓它更容易混淆。 – jsdalton 2011-12-14 19:56:10