PHP Classes

Jade Spark: Process template files using Jade Node.js module

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 173 All time: 8,802 This week: 455Up
Version License PHP version Categories
jade-spark 0.0.2BSD License5.3.0PHP 5, Templates
Description 

Author

This class can process template files using Jade Node.js module.

It can take a given template file in the Jade format and call the Jade module process the template.

The class can encode additional parameters in JSON format to be passed to Jade.

The processed template is displayed as the current script output.

Picture of Leo Daidone
  Performance   Level  
Name: Leo Daidone <contact>
Classes: 2 packages by
Country: Argentina Argentina
Age: 46
All time rank: 323442 in Argentina Argentina
Week rank: 197 Up3 in Argentina Argentina Up

Details

Jade-Spark

This is a small class that let you use Jade-lang template engine.

Requirements:

You will need to have Jade binary installed in your system.

To install via npm:


### Usage:

Create a view template, with `.jade` extension. (check Examples section)
For Jade-lang references click here

In your PHP file create an instance of Jade_spark:

... require_once('jade_spark.php'); $jade = new Jade_spark(); ...


*Jade_spark constructor method support two arguments, the first is for templates root path, defaulted as current directory. 
The second is to set Jade binary full path, defaulted as `/usr/bin/jade`.*

Optionally you can prepare array of variables needed in templates.

Finally, invoke `render` method in your controller, passing template name as first argument and optional array of params as second argument.

... $jade->render("index",$params); ...


### Examples:

PHP

require_once(dirname(__FILE__).'/../jade_spark.php');

$jade = new Jade_spark();

$jade->render('index.jade');


Jade template

doctype html
html
   head
      title "testing Jade Spark"
   body
      div#content
         = "This is my first jade view with PHPClasses!!!"
      hr
      div
         = "For more Jade-lang references:"
         a(href='http://jade-lang.com/reference') Jade-lang API

HTML Result

<!DOCTYPE html>
<html>
    <head>
        <title>"testing Jade Spark"</title>
    </head>
    <body>
        <div id="content">
            This is my first jade view with PHPClasses!!!
        </div>
        <hr>
        <div>
            For more Jade-lang references: <a href="http://jade-lang.com/reference">Jade-lang API</a>
        </div>
    </body>
</html>

  Files folder image Files (6)  
File Role Description
Files folder imageexample (2 files)
Plain text file CLIStatus Class CLI Status
Plain text file Jade_spark Class Jade_spark
Plain text file jade_spark.php Class jade_spark.php
Accessible without login Plain text file README.md Doc. README.markdown

  Files folder image Files (6)  /  example  
File Role Description
  Accessible without login Plain text file example.php Example small example
  Accessible without login Plain text file index.jade Data example of jade template

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:173
This week:0
All time:8,802
This week:455Up