PHP Classes
elePHPant
Icontem

File: README.md

Recommend this page to a friend!
  Classes of Leo Daidone  >  Jade Spark  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: README.markdown
Class: Jade Spark
Process template files using Jade Node.js module
Author: By
Last change:
Date: 5 years ago
Size: 1,901 bytes
 

 

Contents

Class file image Download

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>