Is there only html template template for php?

I started coding in clojure and I was really impressed with Enlive . The only thing I really like about this is that Enlive only uses html templates. So, a template is a file with html in it, ending in .html, simple in that. It is processed in the dom tree, and then this dom tree is processed by clojure / enlive, combined, made dynamic, etc. There are no syntax in html template files, beautifully clean separation.

Another example of such a system running through javascript is PURE .

Is there something similar in php? Or, in general, any ways to make html-only templates?

+5
source share
5 answers

Fascinated to hear about Enlive. I have been thinking about this concept for several years and have cracked something in PHP that shares some principles: templates are pure HTML and you “fill” them by accessing the content on a specific node in the document using CSS or XPath.

$t = new Template('yourfile.html');
$t->fill('#nav',$someMarkup);
$t->fill('#header',$otherMarkup);

I also experimented with creating some clauses to separate content into a “style sheet” ... well, “style sheet” is the wrong word. I call them content addressing lists (the project is called CAST, for a template with a content template). CAS looks like you might expect:

.col #foot {
    content: 'foot';
}

#content {
    content: file_get_contents('pangolin.txt');
}

, PHP. PHP, .

cssfill.php script, tarball ( , , ./cssfill.php pangolin.cas pangolin.html, , , php- cssfill.php), , .

- , , . , , , , tarball, .

+4

phptal.org. PHP, HTML-. .

, twig-project.org, .

+1

PHPTAL. PHPTAL - XML/XHTML PHP5, . XML/HTML.

<div class="item" tal:repeat="item itemsArray">
    <span tal:condition="item/hasDate" tal:replace="item/getDate"/>
    <a href="${item/getUrl}" tal:content="item/getTitle"/>
  <p tal:content="value/getContent"/>
</div>
+1

. , , - . , - html php/js . - .

+1
source

I think Psttt! The templating engine for php is exactly what you are looking for, it keeps your html template intact, allowing you to make better use of htmls.

full source code is here http://github.com/givanz/psttt

0
source

All Articles