shadytrees / Zoetrope

Portable short tags for PHP.

Clone this repository (size: 9.1 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/shadytrees/zoetrope/
View at rev
Zoetrope /
filename size last modified message
lib  
tests  
README.markdown 1.1 KB 13 months ago Documentation: short tags blurb.

README

Motto.

A simple preprocessor PHP library disguised as a PHP templating system.

http://bitbucket.org/shadytrees/zoetrope/

Example.

Instead of

<?php echo("hello") ?>
<?php if ($logged_in): ?>
<div>You're logged in.</div>
<?php endif ?>

<ul>
  <?php foreach ($users as user): ?>
  <li><?php echo $user->name ?></li>
  <?php endforeach ?>
</ul>

you do

{[ "hello" ]}
{{ if ($logged_in): }}
<div>You're logged in.</div>
{{ endif }}

<ul>
  {{ foreach ($users as user): }}
  <li>{[ $user->name ]}</li>
  {{ endforeach }}
</ul>

Why?

  • It's easier to read: PHP no longer looks like HTML.
  • It's way easier to type.
  • It's not a complicated transformation from Zoetrope to PHP's usual templating ways.
  • It's a fun experiment.
  • Most people disable PHP's short tags. Some people do it because they're writing XML/SGML-sensitive code. But most people do it because they hate happiness.

About.

By Hao Lian. Licensed under BSD even if I'm too lazy to create a license file. I promise not to sue you.