Skip to content

LatteView for CakePHP

Bringing the power of Latte templates to your CakePHP application

Latte

📄 layout.latte

latte
<!DOCTYPE html>
<html>
<head>
    {Html charset}
    <title>{block title}Homepage{/block} - My app</title>
    {* $this->Html->css('site') *}
    {Html css 'site'}
    {Html js 'app'}

    {* $this->fetch('meta') *}
    {fetch meta}
    {fetch css}
    {fetch script}
</head>
<body>
    <header>
      <h1>{block title}Latte + CakePHP = Awesome{/block}</h1>
    </header>
    <main>
      {include content}
    </main>
    <footer>
      {block footer}
        Copyright {$today|format:'Y'}
      {/block}
    </footer>
</body>
</html>

📄 add.latte

latte
{block title}Create article{/block}

{block content}
{* $this->Form->create($user) *}
<form n:context="$user">
  <control n:name="first_name" />
  <control n:name="last_name" />
  <control n:name="email" /> 
  <control n:name="password" />
  <control n:name="bio" rows="10" />
  <button type="submit">{_'Save article'}</button>
  <a n:named="users:index">{_'Go back'}</a>
</form>