PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Info   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2015-04-16 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 165 All time: 8,081 This week: 1,068Up
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

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  
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  /  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

 Version Control Unique User Downloads Download Rankings  
 0%
Total:165
This week:0
All time:8,081
This week:1,068Up