php - Mustache partials and code reuse -
i'm getting hang of mustache project i've started during weekend.
i'm using php implementation. have, couple of inquiries i'm not used system.
how handle template inheritance, or reuse? know of partials, how should use them? i'm doing this, ala include:
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>
and view render template:
{{>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 }}
is right approach?
ynkr's answer right older versions, upgraded version 2.4.1 , there approach should work if you're using filesystemloader.
see https://github.com/bobthecow/mustache.php/wiki/template-loading#partials-loading details.
Comments
Post a Comment