2017 © Pedro Peláez
 

library Renderer

A simple PHP component to allow rendering Jade template using the native Jade Compiler

image

PHPNativeJade/Renderer

A simple PHP component to allow rendering Jade template using the native Jade Compiler

  • Wednesday, July 11, 2012
  • by jimthunderbird
  • Repository
  • 3 Watchers
  • 12 Stars
  • 73 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHPNativeJadeRenderer

Render Jade template with PHP using the native Jade Rendering Engine, (*1)

Usage:

1.Globally Install the jade template native compiler using npm install -g jade, (*2)

For more details on npm, please see: http://npmjs.org/, (*3)

2.Write our main php file (assuming the jade compiler is at /usr/local/bin/jade and PHP can run /usr/local/bin/jade with shell_exec function properly), (*4)

For detail usage on Jade Template, please see: https://github.com/visionmedia/jade#readme, (*5)

<?php
require "../src/PHPNativeJade/Renderer.php";

$renderer = new PHPNativeJade\Renderer();
$renderer->setNativeJadeCompiler("/usr/local/bin/jade");
$renderer->render("index.jade", array(
    'items' => array(1,2,3,4,5),
    'students' => array(
        array('name' => 'tom', 'role' => 'editor'),
        array('name' => 'ken', 'role' => 'admin'),
        array('name' => 'john', 'role' => 'visitor')
    ),
    'content' => 'This is a paragraph from the cms <br/>',
));

3.In index.jade we have, (*6)

- if (items.length)
  ul
    - items.forEach(function(item){
      li= item
    - })
for user in students 
  if user.role == 'admin'
    p #{user.name} is an admin
  else
    p= user.name
p= content
p!= content

4.After the main php file is executed, we should see:, (*7)

<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
</ul>
<p>tom</p>
<p>ken is an admin</p>
<p>john</p>
<p>This is a paragraph from the cms &lt;br/&gt;</p>
<p>This is a paragraph from the cms <br/></p>

The Versions

11/07 2012

dev-master

9999999-dev https://github.com/superjimpupcake/PHPNativeJadeRenderer

A simple PHP component to allow rendering Jade template using the native Jade Compiler

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

template php jade node.js