Skip to content

Instantly share code, notes, and snippets.

@alganet
Created April 14, 2011 02:45
Show Gist options
  • Select an option

  • Save alganet/918807 to your computer and use it in GitHub Desktop.

Select an option

Save alganet/918807 to your computer and use it in GitHub Desktop.
Requirements for a next-gen HTML templating engine.
<!doctype html>
<html>
<head>
<title>Hi</title>
<script id="helloworld" type="text/html">
Hello <strong>${user}</strong>
</script>
<script id="secretTemplate" type="text/html" class="php-only">
Sensitive Info!
</script>
</head>
<body>
</body>
</html>
<?php
//Heavily based on and designed to be compatible with jQuery Templates
//See: http://github.com/jquery/jquery-tmpl
$template = new Template();
$template->loadFile('template.html');
$data = array("user" => "Alexandre");
$template("#helloworld")->tmpl($data)->appendTo($template("body"));
echo $template->render();
<!doctype html>
<html>
<head>
<title>Hi</title>
<script id="helloworld" type="text/html">
Hello <strong>${user}</strong>
</script>
</head>
<body>
Hello <strong>Alexandre</strong>
</body>
</html>
@dublado
Copy link

dublado commented Jul 9, 2011

Alguma idéia para blocos que devem ter estrutura de repetição ?

@alganet
Copy link
Author

alganet commented Jul 10, 2011

@dublado provavelmente o padrão do jquery-templates seria seguido: http://api.jquery.com/template-tag-each/

@dublado
Copy link

dublado commented Jul 11, 2011

Serviu perfeitamente!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment