0.5.0 • Published 9 years ago

jade2phtml v0.5.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

jadeToPhtml

  • translate jade to phtml
  • some bugs
  • working on it

install

via npm:

npm install jade2phtml -g

via github:

https://github.com/supersky07/jade2phtml

usage

Usage: jade2phtml {OPTIONS}
Standard Options:
    --origin, -o  jade path with which to convert.
    --destination, -d  phtml path where to save the file.

option

  • origin: the origin jade file path
  • destination: the destination phtml file path

example

With npm install:

jade2phtml -o ./test.jade -d ./test.phtml

With github download:

var jade2phtml = require('jadeToPhtml/index.js');
jade2phtml('./test.jade', './test.phtml');

PS: When you don't specify the second argument, the translated phtml will print to the console.

Jade is a clean, whitespace sensitive syntax for writing html. Here is a simple example:

doctype html
    html(lang="en")
    head
        title= pageTitle
        script(type='text/javascript').
            if (foo) bar(1 + 5)
    body
        h1 Jade - node template engine
        #container.col
            if youAreUsingJade
                p You are amazing
            else
                p Get on it!
            p.
                Jade is a terse and simple templating language with a
                strong focus on performance and powerful features.

After translated to phtml:

<!DOCTYPE html>
    <html lang='en'>
        <head>
            <title>
                <?= $jade->escape($pageTitle) ?>
            </title>
            <script type='text/javascript'>
              if (foo) bar(1  +  5)
            </script>
        </head>
        <body>
            <h1>
                Jade - node template engine
            </h1>
            <div id='container' class='col'>
                <?php if ($youAreUsingJade) { ?>
                <p>
                    You are amazing
                </p>
                <?php } else { ?>
                    <p>
                        Get on it!
                    </p>
                <?php } ?>
                <p>
                    Jade is a terse and simple templating language with a strong focus on
                    performance and powerful features.
                </p>
            </div>
      </body>
</html>

You need a php class named jade

You can find this php file in the core package!

When you want to complie the phtml with data, you should get a instance of this jade class.

<?php
    class jade{
        function merge($a) {
        }

        function mergeTwo($a, $b) {
        }
        
        function joinClasses($val) {
        }
        
        function cls($classes, $escaped) {
        }
        
        function style($val) {
        }
        
        function attr($key, $val, $escaped, $terse) {
        }
        
        function attrs($obj, $terse) {
        }
    }
?>

!!!Do not support

  • jade
    • use extends keword in jade
    • each in grammer in jade
    • mixins in jade
    • self closing eg:foo/
  • js function
    • parseInt
    • parseFloat
    • Number
    • toString
    • Date
    • custom function defination and call
    • Window
    • Document

Work flow

this place has to be a image.

Support Js function

From js2php

  • Classes (ES6)
  • Getters and Setters (ES6)
  • Namespaces (ES6)
  • Loops (while / for / do-while)
  • Functions and closures
  • Conditionals
  • Core JavaScript(core)
    • Array
    • JSON
    • Math
    • String
    • Function

Custom

coming soon!

Tips

  • include && - include()
    • "include" is the function of Jade. When using it, Jade will include the specified file before translating it.
    • "-include()" is a custom grammer. When using it, Jade will ignore it, and jade2phtml will translate it to the php gramer. That is to say, "-include()" is used for php-include.

Next task

  • support extra function for js

license

MIT

0.5.0

9 years ago

0.1.4

9 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.4

10 years ago