From 18019d630369b9c81c399f945cf3016b4fde2aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torben=20K=C3=B6hn?= Date: Tue, 6 Oct 2015 13:51:48 +0200 Subject: [PATCH] First release Removed test files Removed dependencies to other libraries Added: License Added: Readme --- LICENSE.md | 21 +++ README.md | 106 ++++++++++++++- composer.json | 5 +- src/Tale/Jade/Compiler.php | 2 +- src/Tale/Jade/Renderer/Adapter/File.php | 5 +- tests/anti.php | 28 ---- tests/anti/block-without-name.jade | 8 -- tests/anti/nested-mixins.jade | 10 -- tests/anti/unclosed-attribute-block.jade | 3 - tests/compiler.php | 31 ----- tests/lexer.php | 36 ----- tests/nodes.php | 137 -------------------- tests/page/examples/assignments.jade | 13 -- tests/page/examples/attribute-stacking.jade | 40 ------ tests/page/examples/block-expansion.jade | 25 ---- tests/page/examples/blocks.jade | 46 ------- tests/page/examples/code.jade | 25 ---- tests/page/examples/comments.jade | 14 -- tests/page/examples/conditionals.jade | 28 ---- tests/page/examples/doctypes.jade | 16 --- tests/page/examples/escaping.jade | 11 -- tests/page/examples/expressions.jade | 17 --- tests/page/examples/filters.jade | 19 --- tests/page/examples/imports.jade | 23 ---- tests/page/examples/include-filters.jade | 15 --- tests/page/examples/interpolation.jade | 17 --- tests/page/examples/loops.jade | 23 ---- tests/page/examples/mixins.jade | 29 ----- tests/page/examples/text.jade | 23 ---- tests/page/examples/variadics.jade | 11 -- tests/page/examples/welcome.jade | 7 - tests/page/index.php | 75 ----------- tests/page/views/index.jade | 85 ------------ tests/page/views/pages/about.jade | 7 - tests/page/views/pages/more-examples.jade | 5 - tests/page/views/script.js | 52 -------- tests/page/views/scripts.jade | 6 - tests/page/views/style.css | 32 ----- tests/page/views/styles.jade | 4 - tests/parser.php | 48 ------- tests/renderer.php | 27 ---- tests/views/all-features.jade | 14 -- tests/views/all-features/conditionals.jade | 26 ---- tests/views/all-features/elements.jade | 64 --------- tests/views/all-features/layout.jade | 37 ------ tests/views/all-features/mixins.jade | 32 ----- tests/views/all-features/navigation.jade | 9 -- tests/views/index.jade | 12 -- tests/views/layout-basic.jade | 13 -- tests/views/some-include.jade | 10 -- 50 files changed, 129 insertions(+), 1223 deletions(-) create mode 100644 LICENSE.md delete mode 100644 tests/anti.php delete mode 100644 tests/anti/block-without-name.jade delete mode 100644 tests/anti/nested-mixins.jade delete mode 100644 tests/anti/unclosed-attribute-block.jade delete mode 100644 tests/compiler.php delete mode 100644 tests/lexer.php delete mode 100644 tests/nodes.php delete mode 100644 tests/page/examples/assignments.jade delete mode 100644 tests/page/examples/attribute-stacking.jade delete mode 100644 tests/page/examples/block-expansion.jade delete mode 100644 tests/page/examples/blocks.jade delete mode 100644 tests/page/examples/code.jade delete mode 100644 tests/page/examples/comments.jade delete mode 100644 tests/page/examples/conditionals.jade delete mode 100644 tests/page/examples/doctypes.jade delete mode 100644 tests/page/examples/escaping.jade delete mode 100644 tests/page/examples/expressions.jade delete mode 100644 tests/page/examples/filters.jade delete mode 100644 tests/page/examples/imports.jade delete mode 100644 tests/page/examples/include-filters.jade delete mode 100644 tests/page/examples/interpolation.jade delete mode 100644 tests/page/examples/loops.jade delete mode 100644 tests/page/examples/mixins.jade delete mode 100644 tests/page/examples/text.jade delete mode 100644 tests/page/examples/variadics.jade delete mode 100644 tests/page/examples/welcome.jade delete mode 100644 tests/page/index.php delete mode 100644 tests/page/views/index.jade delete mode 100644 tests/page/views/pages/about.jade delete mode 100644 tests/page/views/pages/more-examples.jade delete mode 100644 tests/page/views/script.js delete mode 100644 tests/page/views/scripts.jade delete mode 100644 tests/page/views/style.css delete mode 100644 tests/page/views/styles.jade delete mode 100644 tests/parser.php delete mode 100644 tests/renderer.php delete mode 100644 tests/views/all-features.jade delete mode 100644 tests/views/all-features/conditionals.jade delete mode 100644 tests/views/all-features/elements.jade delete mode 100644 tests/views/all-features/layout.jade delete mode 100644 tests/views/all-features/mixins.jade delete mode 100644 tests/views/all-features/navigation.jade delete mode 100644 tests/views/index.jade delete mode 100644 tests/views/layout-basic.jade delete mode 100644 tests/views/some-include.jade diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..c4da3f9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Talesoft GbR + +Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 8015ab6..a752845 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,104 @@ -# tale-jade -A PHP port of the Jade template engine (http://jade-lang.com) + + +# The Tale Jade Template Engine + +> Finally a fully-functional, complete and clean port of the Jade language to PHP +> *— Abraham Lincoln* + +The Tale Jade Template Engine brings the popular and powerful Templating-Language [Jade for Node.js](http://jade-lang.com) to PHP! + +While previously there only existed ports of the existing Node.js Engine of Jade, **Tale Jade** is a completely new +implementation of the language utilizing the powerful and very specific features of PHP into your Jade application. + +Build dynamic websites faster than ever before! + +[Get started](http://jade.talesoft.io/getting-started) now or [dig into the dirt](http://jade.talesoft.io/hacking) by yourself! + + + +## Supported features + +Tale Jade for PHP does not only implement **every existing feature** of Jade there is, it also brings in some new ones! + +### Supported official Node.js Jade Features +- [Tags](http://jade.talesoft.io/examples/tags) +- [Classes](http://jade.talesoft.io/examples/classes) +- [IDs](http://jade.talesoft.io/examples/ids) +- [Doctypes](http://jade.talesoft.io/examples/doctypes) +- [Attributes](http://jade.talesoft.io/examples/attributes) +- [Mixins](http://jade.talesoft.io/examples/mixins) +- [Blocks (with prepend, append and replace support)](http://jade.talesoft.io/examples/blocks) +- [Expressions & Escaping](http://jade.talesoft.io/examples/expressions) +- [Block Expansion](http://jade.talesoft.io/examples/block-expansion) +- [Assignments (&attributes)](http://jade.talesoft.io/examples/assignments) +- [Comments](http://jade.talesoft.io/examples/comments) +- [Inline Code](http://jade.talesoft.io/examples/code) +- [Inheritance](http://jade.talesoft.io/examples/inheritance) +- [Includes (with filters)](http://jade.talesoft.io/examples/includes) +- [Conditionals (if, else, elseif, case, when)](http://jade.talesoft.io/examples/conditionals) +- [Loops (each, while, do)](http://jade.talesoft.io/examples/loops) +- [Interpolation (with Element Interpolation)](http://jade.talesoft.io/examples/interpolation) +- [Filters](http://jade.talesoft.io/examples/filters) +- [Mixin Blocks](http://jade.talesoft.io/examples/mixin-blocks) +- [Variadics](http://jade.talesoft.io/examples/variadics) + + +### Supported Tale Jade Features +- [Named parameters](http://jade.talesoft.io/examples/named-parameters) +- [Attribute Stacking](http://jade.talesoft.io/examples/attribute-stacking) +- [Filter Maps](http://jade.talesoft.io/examples/filter-map) +- [Cross Assignments](http://jade.talesoft.io/examples/cross-assignments) + + +### Other, unrelated, cool features + +- UTF-8 support via PHP's mb_* extension +- Hackable compiler, parser and lexer +- Huge amount of (optional) configuration possibilities +- Graceful compiler forgiving many mistakes (e.g. spaces around the code) +- Lightning fast and clean compilation +- Detailed error handling +- Renderer with different adapters (ease-of-use vs. performance) +- Intelligent expression parsing + + + +## Getting started + +To install and use the Tale Jade library, follow our [Getting Started](http://jade.talesoft.io/getting-started) guide. + +If you're interested, you might also look into our in-depth guides: + +- [In-depth configuration](http://jade.talesoft.io/configuration) +- [Hacking Tale Jade](http://jade.talesoft.io/hacking) + + + +## There's more to come... + +Tale Jade is actively used and developed in many projects and is improved constantly. + +We don't stick to the Jade-convention, but we'll always provide compatibility to Node.js Jade to +help reducing confusion. + +Planned features: +[ ] Import Attributes (`include some-file(some-var='some-value')`) +[ ] Helper Libraries +[ ] Aliases (Like mixins, just smaller) + + + +## Get in touch + +If you find a bug or miss a function, please use the [Issues](https://github.com/Talesoft/tale-jade/issues) on this page +to tell us about it. We will gladly hear you out :) + +If you'd like to contribute, fork us, send us pull requests and we'll take a deep look at what you've been working at! +We're completely **Open Source**! You can do anything you like with out code, as long as you stick to the +**MIT-license** we've appended. + +You can also contact us via E-Mail. + +If you're interested in other projects, you might also contact us via E-Mail as well + +**E-Mail: [info@talesoft.io](mailto:info@talesoft.io)** \ No newline at end of file diff --git a/composer.json b/composer.json index 8784504..d3c733d 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,9 @@ { "name": "talesoft/tale-jade", - "description": "A PHP port of the Jade template engine", + "description": "The Jade Template Engine for PHP!", "type": "library", "require": { - "talesoft/tale-util": ">=1.0", - "php": ">=5.6.0" + "php": ">=5.5.0" }, "autoload": { "psr-0": { diff --git a/src/Tale/Jade/Compiler.php b/src/Tale/Jade/Compiler.php index f2701a8..557aeab 100644 --- a/src/Tale/Jade/Compiler.php +++ b/src/Tale/Jade/Compiler.php @@ -336,7 +336,7 @@ public function resolvePath($path, $extension = null) foreach ($paths as $directory) { - $fullPath = realpath(PathUtil::join($directory, $path)); + $fullPath = realpath(rtrim($directory, '/\\').'/'.ltrim($path, '/\\')); if ($fullPath) return $fullPath; diff --git a/src/Tale/Jade/Renderer/Adapter/File.php b/src/Tale/Jade/Renderer/Adapter/File.php index 16c10b8..1d29b04 100644 --- a/src/Tale/Jade/Renderer/Adapter/File.php +++ b/src/Tale/Jade/Renderer/Adapter/File.php @@ -40,10 +40,7 @@ public function render($path, array $args = null) if (substr($path, -strlen($ext)) === $ext) $path = substr($path, 0, -strlen($ext)); - $outputPath = PathUtil::join( - $this->getOption('outputDirectory'), - $path.$this->getOption('extension') - ); + $outputPath = rtrim($this->getOption('outputDirectory'), '/\\').'/'.ltrim($path.$this->getOption('extension'), '/\\'); $render = function($__path, $__args) { diff --git a/tests/anti.php b/tests/anti.php deleted file mode 100644 index f23b103..0000000 --- a/tests/anti.php +++ /dev/null @@ -1,28 +0,0 @@ -Testing '.basename($path, '.jade').'
'; - - try { - - $jade = $compiler->compileFile($path); - - echo 'Failed
'; - } catch(Exception $e) { - - echo 'Passed
'; - } - - echo '
'; -} \ No newline at end of file diff --git a/tests/anti/block-without-name.jade b/tests/anti/block-without-name.jade deleted file mode 100644 index 6266cda..0000000 --- a/tests/anti/block-without-name.jade +++ /dev/null @@ -1,8 +0,0 @@ - - -doctype 5 -html(lang='en') - head - body - - block \ No newline at end of file diff --git a/tests/anti/nested-mixins.jade b/tests/anti/nested-mixins.jade deleted file mode 100644 index 88b8940..0000000 --- a/tests/anti/nested-mixins.jade +++ /dev/null @@ -1,10 +0,0 @@ - -mixin mixin-level-1(arg1, arg2) - - h1 Mixin Level 1 - p Mixin Content Level 1 - - mixin mixin-level-2(arg1, arg2) - - h1 Mixin Level 2 - p Mixin Content Level 2 \ No newline at end of file diff --git a/tests/anti/unclosed-attribute-block.jade b/tests/anti/unclosed-attribute-block.jade deleted file mode 100644 index 75b0883..0000000 --- a/tests/anti/unclosed-attribute-block.jade +++ /dev/null @@ -1,3 +0,0 @@ - - -some-tag(some-attribute \ No newline at end of file diff --git a/tests/compiler.php b/tests/compiler.php deleted file mode 100644 index 130a962..0000000 --- a/tests/compiler.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - -
-
-                views/index.jade\n";
-                echo file_get_contents('views/index.jade');
-                ?>
-            
-
-
-                views/index.jade\n";
-                echo htmlentities($compiler->compileFile('views/index.jade'), ENT_QUOTES);
-                ?>
-            
-
\ No newline at end of file diff --git a/tests/lexer.php b/tests/lexer.php deleted file mode 100644 index eb6f47c..0000000 --- a/tests/lexer.php +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - -
-
-                views/index.jade\n";
-                    echo file_get_contents('views/index.jade');
-
-                    echo "\n\nviews/layout-basic.jade\n";
-                    echo file_get_contents('views/layout-basic.jade');
-                ?>
-            
-
-
-                views/index.jade\n";
-                    $lexer->dump(file_get_contents('views/index.jade'));
-
-                    echo "\n\nviews/layout-basic.jade\n";
-                    $lexer->dump(file_get_contents('views/layout-basic.jade'));
-                ?>
-            
-
\ No newline at end of file diff --git a/tests/nodes.php b/tests/nodes.php deleted file mode 100644 index 12e8b89..0000000 --- a/tests/nodes.php +++ /dev/null @@ -1,137 +0,0 @@ -'.$message.''; - } - - $passes++; - return 'Passed!'; -} - -$tests = [ - 'indexOf' => function() { - - $node = new Node('parent'); - $node->append(new Node('child-1')); - $node->append($secondChild = new Node('child-2')); - $node->append($thirdChild = new Node('child-3')); - - $notAChild = new Node('not-a-child'); - - yield check($node->indexOf($secondChild) === 1, 'Second child is not 1'); - yield check($node->indexOf($thirdChild) === 2, 'Third child is not 2'); - yield check($node->indexOf($notAChild) === false, 'notAChild is not false'); - }, - 'append' => function() { - - $node = new Node('parent'); - $node->append(new Node('child-1')); - $node->append(new Node('child-2')); - $node->append(new Node('child-3')); - - $notAChild = new Node('not-a-child'); - - check(count($node->children) === 3, 'Child count is not 3'); - - $validParent = true; - foreach ($node->children as $childNode) - if ($childNode->parent !== $node) - $validParent = false; - yield check($validParent, 'Parent not correctly set'); - }, - 'prepend' => function() { - - $node = new Node('parent'); - $node->append(new Node('child-1')); - $node->prepend($secondChild = new Node('child-2')); - $node->prepend($thirdChild = new Node('child-3')); - - $notAChild = new Node('not-a-child'); - - yield check(count($node->children) === 3, 'Child count is not 3'); - - $validParent = true; - foreach ($node->children as $childNode) - if ($childNode->parent !== $node) - $validParent = false; - yield check($node->indexOf($secondChild) === 1, 'Second child not 1'); - yield check($node->indexOf($thirdChild) === 0, 'Third child not 0'); - yield check($validParent, 'Parent not correctly set'); - }, - 'remove' => function() { - - $node = new Node('parent'); - $node->append(new Node('child-1')); - $node->append($secondChild = new Node('child-2')); - $node->append($thirdChild = new Node('child-3')); - - $notAChild = new Node('not-a-child'); - - $node->remove($secondChild); - - yield check($node->indexOf($secondChild) === false, 'Child still in parent node'); - yield check($secondChild->parent === null, 'Childs parent not null'); - yield check($node->indexOf($thirdChild) === 1, 'Third child not moved to 1'); - }, - 'insertAfter' => function() { - - $node = new Node('parent'); - $node->append($firstChild = new Node('child-1')); - $node->append($secondChild = new Node('child-2')); - $node->insertAfter($firstChild, $thirdChild = new Node('child-3')); - - $notAChild = new Node('not-a-child'); - - yield check(count($node->children) === 3, 'Child count not 3'); - yield check($node->indexOf($thirdChild) === 1, 'Third child not 1'); - yield check($node->indexOf($secondChild) === 2, 'Second child not 2'); - }, - 'insertBefore' => function() { - - $node = new Node('parent'); - $node->append($firstChild = new Node('child-1')); - $node->append($secondChild = new Node('child-2')); - $node->insertBefore($secondChild, $thirdChild = new Node('child-3')); - - $notAChild = new Node('not-a-child'); - - yield check(count($node->children) === 3, 'Child count not 3'); - yield check($node->indexOf($thirdChild) === 1, 'Third child not 1'); - yield check($node->indexOf($secondChild) === 2, 'Second child not 2'); - } -]; - - - -echo '

Testing node functionality

'; - -ob_start(); -foreach ($tests as $name => $test) { - - echo '

Testing '.$name.':


'; - - foreach ($test() as $result) { - - echo "$result
"; - } -} -$results = ob_get_clean(); - -echo "

Tests: $testCount, Passes: $passes, Fails: $fails


"; -echo $results; \ No newline at end of file diff --git a/tests/page/examples/assignments.jade b/tests/page/examples/assignments.jade deleted file mode 100644 index 8492268..0000000 --- a/tests/page/examples/assignments.jade +++ /dev/null @@ -1,13 +0,0 @@ - -h1 Cross Assignments - -p Assign complex values to attributes easily without repeating the attribute name - - -- $classes = ['class-1', 'class-2', 'class-3'] -div&classes($classes) - - -div&classes('class-1', 'class-2', 'class-3') - -div&data-complex((object)['a' => 1, 'b' => 2]) \ No newline at end of file diff --git a/tests/page/examples/attribute-stacking.jade b/tests/page/examples/attribute-stacking.jade deleted file mode 100644 index 2c1a6e1..0000000 --- a/tests/page/examples/attribute-stacking.jade +++ /dev/null @@ -1,40 +0,0 @@ - - -h1 Attribute Stacking - -p Repeative attributes append to their value - -a(href=$baseUrl, href='&page=#{$page}', href='##{$action}') - - -- $parts = [$baseUrl, "&page=$page", "#$action"]; -a&href($parts) - - -p Classes get appended with a space -div(class=col, class='col-1', class=$col3)&class(['col-4', $col5]) - - -p Style gets converted automatically -div(style=['width' => '100%', 'background' => 'red'], style=['height' => '20px']) - -- $styles = ['color' => 'black', 'font-size' => '15px'] -div&style($styles) - -div(style=['color' => 'red', 'font-size' => '12px'], style=['height' => '20px', [['width' => '200px']]])&style(['background' => 'yellow']) - | Test - - -p data-* Attributes convert to JSON automatically -div(data-some-var=['a', 'b', 'c'], data-some-var=['d'], data-some-var='e') - - -p The URL of this site is put together as follows internally -mixin example-button(label, example, withErrorHandler) -//- Nifty, isn't it? -a.btn.btn-default.btn-lg&href( - $url, - '?example='.$example, - $withErrorHandler ? '&withErrorHandler': '', - '#liveCompiler' -)= $label \ No newline at end of file diff --git a/tests/page/examples/block-expansion.jade b/tests/page/examples/block-expansion.jade deleted file mode 100644 index 84edcaf..0000000 --- a/tests/page/examples/block-expansion.jade +++ /dev/null @@ -1,25 +0,0 @@ - - - -h1 Block Expansion via : - - -nav: ul - li: a(href='#') 1 - li: a(href='#'): if $variable: some.element - li: a(href='#') 3 - - -- $var = true - -if $var: p This should be printed through block expansion - - -if (true ? true : false): p This should be printed through block expansion - - -- $i = 15 -while $i-- > 0: p Counter: #{$i} - -- $array = ['key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'] -each $value, $key in $array: p Foreach #{$key} => #{$value} diff --git a/tests/page/examples/blocks.jade b/tests/page/examples/blocks.jade deleted file mode 100644 index 9ff632d..0000000 --- a/tests/page/examples/blocks.jade +++ /dev/null @@ -1,46 +0,0 @@ - - -h1 Blocks! - -p Load stuff only when you need it. -p Notice that blocks work through includes/extends - -block scripts - script(src='first-script') - -block styles - style(name='first-style') - -block content - h1 Some bogus content - p This will be replaced! - -block append scripts - script(src='second-script') - -// or just -append styles - style(name='second-style') - - -block prepend scripts - script(src='new-first-script') - -prepend styles - script(name='new-first-style') - - -// Whole replacement - -block replace content - h1 I will be replaced as well - -// or -replace content - h1 I will be replaced, too - -// or -block content - h1 I will stay now, for sure! - p This is my final content :) - diff --git a/tests/page/examples/code.jade b/tests/page/examples/code.jade deleted file mode 100644 index 01e0996..0000000 --- a/tests/page/examples/code.jade +++ /dev/null @@ -1,25 +0,0 @@ - - -//Official jade suggests a - prefix for single-line code - -- $var = 'Some code' - - -- for($i = 0; $i < 20; $i++): - | I is #{$i} -- endfor; - -//In Tale-Jade you can also use it multi-line -- - class SomeFilter extends Filter - { - public function filter($value) - { - return trim($value, '"'); - } - } - - $i = 15; - - //PHP comment - $filter = new Filter(); \ No newline at end of file diff --git a/tests/page/examples/comments.jade b/tests/page/examples/comments.jade deleted file mode 100644 index 675bdb0..0000000 --- a/tests/page/examples/comments.jade +++ /dev/null @@ -1,14 +0,0 @@ - - -//Single line Markup comment - -// - Multiline comment - All following lines on this level - will also be comment - -//- To stop rendering the comment use the - prefix - -//- - The comment will still be there, - but it wont be rendered! \ No newline at end of file diff --git a/tests/page/examples/conditionals.jade b/tests/page/examples/conditionals.jade deleted file mode 100644 index bc64826..0000000 --- a/tests/page/examples/conditionals.jade +++ /dev/null @@ -1,28 +0,0 @@ - - -- $action = 'blog' - -case $action - default - when 'index' - when 'start' - p Start - when 'blog' - p Blog - when 'about' - p About - - -if $someCondition - p Printed when if -elseif $someOtherCondition - p Printed when elseif -else if $someOtherCondition - p Printed when else if -else - p Printed when else - - -unless $error - .success - p Successfully done something! \ No newline at end of file diff --git a/tests/page/examples/doctypes.jade b/tests/page/examples/doctypes.jade deleted file mode 100644 index de11bd7..0000000 --- a/tests/page/examples/doctypes.jade +++ /dev/null @@ -1,16 +0,0 @@ - - -doctype 5 - -!!! 5 - -doctype xml - -doctype html - -!!! transitional - -!!! mobile - - -doctype my awesome custom doctype \ No newline at end of file diff --git a/tests/page/examples/escaping.jade b/tests/page/examples/escaping.jade deleted file mode 100644 index 0e573d9..0000000 --- a/tests/page/examples/escaping.jade +++ /dev/null @@ -1,11 +0,0 @@ - -//Values consisting of alphanumeric characters and surrounded by quotes will not be escaped -div(attr='This is not escaped') - - -//Normal attributes are always escaped, if they are an expression -- $var = 'This is & " ; escaped' -div(attr=$var) - -//Disable escaping with the !-prefix -div(attr!=$var) \ No newline at end of file diff --git a/tests/page/examples/expressions.jade b/tests/page/examples/expressions.jade deleted file mode 100644 index 6a0946d..0000000 --- a/tests/page/examples/expressions.jade +++ /dev/null @@ -1,17 +0,0 @@ - - -h1 Expressions - -div - = $someVariable - = (is_array($var) ? implode(', ', $var) : $var) - - -h2 Avoid escaping - != $someVariable - - -h2 Directly append to elements - ul - li: a(href='#')= $item1 - li: a(href='#')!= $item2 \ No newline at end of file diff --git a/tests/page/examples/filters.jade b/tests/page/examples/filters.jade deleted file mode 100644 index 6e4cac0..0000000 --- a/tests/page/examples/filters.jade +++ /dev/null @@ -1,19 +0,0 @@ - - -h1 Filters! - -:js - var someVar = 14; - doSomething(); - - -:css - - body, html { - height: 100%; - } - -:php - - $var = 15; - doSomething(); \ No newline at end of file diff --git a/tests/page/examples/imports.jade b/tests/page/examples/imports.jade deleted file mode 100644 index 4c67868..0000000 --- a/tests/page/examples/imports.jade +++ /dev/null @@ -1,23 +0,0 @@ - - -h1 These wont get compiled, but you see how they work - - -//layout.jade -doctype 5 -html - head - - include styles - body - block content - - include scripts - - - -//index.jade -extends layout - -append content - h1 Welcome to Jade! \ No newline at end of file diff --git a/tests/page/examples/include-filters.jade b/tests/page/examples/include-filters.jade deleted file mode 100644 index 26521ab..0000000 --- a/tests/page/examples/include-filters.jade +++ /dev/null @@ -1,15 +0,0 @@ - - -h1 Includes can work with filters - - -include some-style.css -//will automatically be converted to and include plain-text - - -include:css some-style -//Will automatically be converted to and include plain-text - -include:plain some-jade-file - -//Will display a jade-file in plain-text \ No newline at end of file diff --git a/tests/page/examples/interpolation.jade b/tests/page/examples/interpolation.jade deleted file mode 100644 index e7c62ad..0000000 --- a/tests/page/examples/interpolation.jade +++ /dev/null @@ -1,17 +0,0 @@ - -p Welcome, #{$userName}! - -a(href=$baseUrl, href='?page=#{page}') - - -script. - - var photos = !{$photos}; - - - -p. - Tag Interpolation Example - Take a look at my awesome #[a(href='#blog') Blog]! - - #[table.table-striped.table-bordered: tr.row: td#tableCell Test!] \ No newline at end of file diff --git a/tests/page/examples/loops.jade b/tests/page/examples/loops.jade deleted file mode 100644 index edfaeee..0000000 --- a/tests/page/examples/loops.jade +++ /dev/null @@ -1,23 +0,0 @@ - - -- $i = 20 -while $i-- > 0 - p Current: #{$i} - - -do - p Current: #{$i} -while $i++ < 20 - - - -each $item in $items - p What's up, #{$item}? - -each $item, $key in $items - p Hello #{$item}, you're #{$key}! - - -//You can actually omit the $ in the key and value if you like -each item, key in $items - p Hello #{$item}, you're #{$key}! \ No newline at end of file diff --git a/tests/page/examples/mixins.jade b/tests/page/examples/mixins.jade deleted file mode 100644 index 4a5448a..0000000 --- a/tests/page/examples/mixins.jade +++ /dev/null @@ -1,29 +0,0 @@ - - -h1 Mixin Example - - -mixin bootstrap-button(label, theme='default') - - a.btn(class='btn-'.$theme)= $label - - -mixin bootstrap-carousel - - .carousel - // Code for bootstrap carousel - - -//Attribute forwarding -mixin alias - p.class-1&classes($class) - - -p Watch mah buttons! -+bootstrap-button('Send') -+bootstrap-button('Reply', 'info') - -p Notice how the bootstrap-carousel mixin isn't rendered, because we didnt use it! - - -+alias.class-2.class-3&classes('class-4', 'class-5') diff --git a/tests/page/examples/text.jade b/tests/page/examples/text.jade deleted file mode 100644 index 2836df4..0000000 --- a/tests/page/examples/text.jade +++ /dev/null @@ -1,23 +0,0 @@ - -h1 Text - -div - | Some text - | Some further text - - -| Now here: - Multiline pretty possible. - Just go on and on... - - -h2 Directly append to element! - - -h2 Enter text-mode with .-suffix - -p. - Here can be endless text until we outdent. - It's multiline - - demacia. \ No newline at end of file diff --git a/tests/page/examples/variadics.jade b/tests/page/examples/variadics.jade deleted file mode 100644 index ab425dd..0000000 --- a/tests/page/examples/variadics.jade +++ /dev/null @@ -1,11 +0,0 @@ - - -mixin variadic-mixin(title, ...posts) - - h1 Title - - each post in $posts - p= $post - - -+variadic-mixin('News', 'Post 1', 'Post 2', 'Post 3') \ No newline at end of file diff --git a/tests/page/examples/welcome.jade b/tests/page/examples/welcome.jade deleted file mode 100644 index bb73713..0000000 --- a/tests/page/examples/welcome.jade +++ /dev/null @@ -1,7 +0,0 @@ - -h1 Welcome to Tale Jade - -p On the right you can see the generated PHTML - -- $notice = "Notice our examples below!" -strong= $notice \ No newline at end of file diff --git a/tests/page/index.php b/tests/page/index.php deleted file mode 100644 index 256f1a3..0000000 --- a/tests/page/index.php +++ /dev/null @@ -1,75 +0,0 @@ - !$minify, - 'handleErrors' => $handleErrors, - 'allowImports' => false - ]); - - $jade = isset($_POST['jade']) ? $_POST['jade'] : ''; - - header('Content-Type: text/plain; encoding=utf-8'); - - try { - echo json_encode($compiler->compile(str_replace("\t", ' ', $jade))); - } catch(Exception $e) { - - echo json_encode($e->getMessage()); - } - exit; -} - - -$renderer = new Renderer([ - 'compiler' => [ - 'pretty' => true - ], - 'adapter' => 'file', - 'adapterOptions'=> [ - 'lifeTime' => 0 - ] -]); - - -$example = isset($_GET['example']) ? $_GET['example'] : 'welcome'; -$exampleJade = ''; - - -$example = preg_replace('/[^a-z0-9\-]+/i', '', $example); -if (file_exists(__DIR__.'/examples/'.$example.'.jade')) - $exampleJade = file_get_contents(__DIR__.'/examples/'.$example.'.jade'); - -$action = isset($_GET['page']) ? preg_replace('/^[a-z0-9\-]+$/i', '', $_GET['example']) : 'index'; -$exampleJade = json_encode($exampleJade); -$url = $_SERVER['PHP_SELF']; - - -header('Content-Type: text/html; encoding=utf-8'); -mb_internal_encoding('UTF-8'); -ob_start('mb_output_handler'); - -echo $renderer->render('views/index', [ - 'action' => $action, - 'example' => $example, - 'exampleJade' => $exampleJade, - 'url' => $url, - 'minify' => json_encode($minify), - 'handleErrors' => json_encode($handleErrors) -]); - diff --git a/tests/page/views/index.jade b/tests/page/views/index.jade deleted file mode 100644 index 0f3dbbb..0000000 --- a/tests/page/views/index.jade +++ /dev/null @@ -1,85 +0,0 @@ - -mixin example-button(label, example, withErrorHandler) - //- Nifty, isn't it? - a.btn.btn-default.btn-lg&href( - $url, - '?example='.$example, - $withErrorHandler ? '&withErrorHandler': '', - '#liveCompiler' - )= $label - -doctype 5 -html(lang='en') - head - meta(charset='utf-8') - title Tale Jade Live Compiler - - include styles - body - - .container - - .page-header - h1 Welcome to Tale Jade! - - p.lead Tale Jade is a PHP Template Engine based on the Node.js Implementation of the Jade Language - - p You can find the original documentation at jade-lang.com - - h4 Tale Jade is not a port of the Node.js Implementation - - p - | While the official implementation works fine for JavaScript, it has its limits in PHP. - | This implementation aims to improve the experience for PHP users using the Jade template engine - - h4 Unlimited Jade - - p Tale Jade removes many limits of the official Node.js implementation. To see how that turned out, watch our examples - - a(name='liveCompiler') - p.lead Check out our live compiler: - .container-editor - .row - - .col.col-md-6 - p.lead Jade - .editor.editor-jade - #jadeEditor - - .col.col-md-6 - p.lead PHTML (HTML with PHP Instructions) - .editor.editor-php - #phpEditor - - .container-examples - - h2 Some more examples - - +example-button('Mixins', 'mixins') - +example-button('Cross Assignment', 'assignments') - +example-button('Blocks', 'blocks') - +example-button('Block Expansion', 'block-expansion') - +example-button('Conditionals', 'conditionals') - +example-button('Loops', 'loops') - +example-button('Escaping', 'escaping') - +example-button('Code', 'code') - +example-button('Comments', 'comments') - +example-button('Error Handler', $example, true) - +example-button('Doctypes', 'doctypes') - +example-button('Interpolation', 'interpolation') - +example-button('Imports', 'imports') - +example-button('Filters', 'filters') - +example-button('Attribute Stacking', 'attribute-stacking') - +example-button('Expressions', 'expressions') - +example-button('Text', 'text') - +example-button('Include Filters', 'include-filters') - +example-button('Variadics', 'variadics') - - - - case $action - when 'about': include pages/about - when 'more-examples': include pages/more-examples - - - include scripts \ No newline at end of file diff --git a/tests/page/views/pages/about.jade b/tests/page/views/pages/about.jade deleted file mode 100644 index ac6013d..0000000 --- a/tests/page/views/pages/about.jade +++ /dev/null @@ -1,7 +0,0 @@ - - -h1 About Tale Jade - -p Tale Jade is different from most Jade ports to PHP, since it's not based on the original Node.js compiler. -p Tale jade was written from scratch, optimized to integrate into PHP -p While the Node.js Engine is great for JavaScript, PHP has some language constructs that allow us to gain a richer feature set \ No newline at end of file diff --git a/tests/page/views/pages/more-examples.jade b/tests/page/views/pages/more-examples.jade deleted file mode 100644 index 1beb220..0000000 --- a/tests/page/views/pages/more-examples.jade +++ /dev/null @@ -1,5 +0,0 @@ - - -h1 More Examples - -p More Examples... \ No newline at end of file diff --git a/tests/page/views/script.js b/tests/page/views/script.js deleted file mode 100644 index cca8510..0000000 --- a/tests/page/views/script.js +++ /dev/null @@ -1,52 +0,0 @@ -$(function() { - - ace.config.set("packaged", true); - ace.config.set("basePath", 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.0'); - - var jadeEditor = ace.edit('jadeEditor'); - var phpEditor = ace.edit('phpEditor'); - - jadeEditor.setTheme('ace/theme/xcode'); - jadeEditor.getSession().setMode('ace/mode/jade'); - jadeEditor.getSession().setUseWorker(false) - jadeEditor.getSession().setUseSoftTabs(true); - jadeEditor.setValue(!{$exampleJade}); - jadeEditor.navigateFileStart(); - phpEditor.setTheme('ace/theme/xcode'); - phpEditor.getSession().setMode('ace/mode/php'); - phpEditor.getSession().setUseWorker(false) - phpEditor.getSession().setUseSoftTabs(true); - phpEditor.setReadOnly(true); - - - function compile() - { - - document.getElementById('phpEditor').classList.add('compiling'); - - var eh = !{$handleErrors} ? '&withErrorHandler' : ''; - var m = !{$minify} ? '&minify' : ''; - $.post('!{$url}?' + eh + m, {jade: jadeEditor.getValue()}, function(result) { - - document.getElementById('phpEditor').classList.remove('compiling'); - phpEditor.setValue(JSON.parse(result)); - phpEditor.navigateFileStart(); - }); - } - - var iv; - function changed() - { - - if (iv) { - - window.clearTimeout(iv); - } - - document.getElementById('phpEditor').classList.add('compiling'); - iv = window.setTimeout(compile, 50); - } - - jadeEditor.getSession().on('change', changed); - compile(); -}); \ No newline at end of file diff --git a/tests/page/views/scripts.jade b/tests/page/views/scripts.jade deleted file mode 100644 index 5212009..0000000 --- a/tests/page/views/scripts.jade +++ /dev/null @@ -1,6 +0,0 @@ - -script(src='//cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js') -script(src='//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js') -script(src='//cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ace.min.js') -script(src='//cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/theme-dreamweaver.js') -include:js script \ No newline at end of file diff --git a/tests/page/views/style.css b/tests/page/views/style.css deleted file mode 100644 index bff4f59..0000000 --- a/tests/page/views/style.css +++ /dev/null @@ -1,32 +0,0 @@ -body { - font-family: 'Segoe UI', 'San Francisco', 'Helvetica Neue', Helvetica, Arial, sans-serif; - font-size: 16px; - padding-bottom: 100px; -} - -pre { - display: block; - border-radius: 0; - background: #fff; - border: none; - width: 100%; - height: 100%; - overflow: auto; -} - -#phpEditor, #jadeEditor, .CodeMirror { - width: 100%; - height: 100%; -} - -.editor { - width: 100%; - height: 600px; - border: 3px solid lawngreen; - transition: border-color .2s ease-out; - border-radius: 2px; -} - -.compiling { - border-color: darkgreen; -} \ No newline at end of file diff --git a/tests/page/views/styles.jade b/tests/page/views/styles.jade deleted file mode 100644 index d4e7466..0000000 --- a/tests/page/views/styles.jade +++ /dev/null @@ -1,4 +0,0 @@ - - -link(rel='stylesheet', href='//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css') -include style.css \ No newline at end of file diff --git a/tests/parser.php b/tests/parser.php deleted file mode 100644 index 5e0686f..0000000 --- a/tests/parser.php +++ /dev/null @@ -1,48 +0,0 @@ - ['./views'] -]); -?> - - - - - -
-
-                views/index.jade\n";
-                $i = 0;
-                echo implode("\n", array_map(function($line) use(&$i) {
-
-                    $i++;
-                    return "$i: $line";
-                }, explode("\n", file_get_contents('views/index.jade'))));
-
-                $i = 0;
-                echo "\n\nviews/layout-basic.jade\n";
-                echo implode("\n", array_map(function($line) use(&$i) {
-
-                    $i++;
-                    return "$i: $line";
-                }, explode("\n", file_get_contents('views/layout-basic.jade'))));
-                ?>
-            
-
-
-                views/index.jade\n";
-                echo $parser->parse(file_get_contents('views/index.jade'));
-
-                echo "\n\nviews/layout-basic.jade\n";
-                echo $parser->parse(file_get_contents('views/layout-basic.jade'));
-                ?>
-            
-
\ No newline at end of file diff --git a/tests/renderer.php b/tests/renderer.php deleted file mode 100644 index 9ad5da3..0000000 --- a/tests/renderer.php +++ /dev/null @@ -1,27 +0,0 @@ - ['pretty' => false] -]); -?> - - -
- '; - echo htmlentities($renderer->compileFile('views/all-features'), ENT_QUOTES); - echo ''; - ?> -
- - - -render('views/all-features'); -?> diff --git a/tests/views/all-features.jade b/tests/views/all-features.jade deleted file mode 100644 index d0b4522..0000000 --- a/tests/views/all-features.jade +++ /dev/null @@ -1,14 +0,0 @@ - -extends all-features/layout - -block content - - h1 Block Content - p This should have replaced the previous some-parent:block content - -include all-features/mixins -include all-features/elements -include all-features/conditionals - - - diff --git a/tests/views/all-features/conditionals.jade b/tests/views/all-features/conditionals.jade deleted file mode 100644 index ee43e72..0000000 --- a/tests/views/all-features/conditionals.jade +++ /dev/null @@ -1,26 +0,0 @@ - -append content - - h1 Conditionals - - - $expression1 = (5 < 3) //false - - $expression2 = (5 > 3) //true - - if $expression1 - p EXP1 This shouldnt be shown - else - - if $expression2 - p EXP2 This should be shown - else - p EXP2 This shouldnt be shown - - - $animal = 'elephant' - - if $animal === 'elephant' - p IF Animal is an elephant - - unless $animal !== 'elephant' - p UNLESS Animal is an elephant - - diff --git a/tests/views/all-features/elements.jade b/tests/views/all-features/elements.jade deleted file mode 100644 index 6537cfd..0000000 --- a/tests/views/all-features/elements.jade +++ /dev/null @@ -1,64 +0,0 @@ - -append content - - h1 Elements - -

Inline Element

-
- Nothing stops you from using plain HTML!
-

Just make sure the line starts with < after the indentation -

- - - h3 The most basic representation - - input - - h3 Nested - table - tr - td: a(href='#') Cell 1 - td: a(href='#') Cell 2 - td: a(href='#') Cell 3 - - h3 Selector classes - div.col.col-md-15 Some Div - - h4 Without a tag it defaults to "div" - .col.col-md-16 Some Div - - h3 Selector ID - div#someContainer1 Some Div - - h4 Without a tag it defaults to "div" - #someContainer2 Some Div - - h4 Attributes - input(type='password', placeholder='*******') - - h5 Attributes stack - div.col(class=col-md-1, class=col-md-2).col-md-3#someId.col-md-4 Some DIV Content - div#someId(id=someId1, id=someId2) - - - h5 Array / Expression values - div.col( - class=col-md-1, class="col-md-2", class="col-md-3", - class=['col-md-4', "col-md-5", (true ? 'col-md-6' : "col-md-7")], - class=['col-md-7'] - ) - - - $varContent = 'Some random variable content' - textarea. - some text content - and here comes #{$varContent} - - - h5 Cross assignment - - $classes = ['col-md-3', 'col-md-4', 'col-md-5'] - div.col(class=col-md-1, class=col-md-2)&classes($classes)&classes('col-md-6', col-md-7) - - h6 Automatic JSON representation - div(some-stuff=['a', 'b', 'c']) - div(some-stuff=(object)['a', 'b', 'c']) - diff --git a/tests/views/all-features/layout.jade b/tests/views/all-features/layout.jade deleted file mode 100644 index 9d34568..0000000 --- a/tests/views/all-features/layout.jade +++ /dev/null @@ -1,37 +0,0 @@ - -if $xml - !!! xml -else - doctype 5 -html(lang=isset($language) ? $language : 'en') - head - meta(charset=isset($charset) ? $charset : 'utf-8') - title= isset($title) ? $title : 'My Jade Website' - - - block styles - style. - body, html { - height: 100%; - } - style. - p { line-height: 2; } - -body - - include navigation - - block content - h1 This is default content - p Replace it as soon as possible - - block scripts - script var someVar = doSomeJavaScript || 'Do something else' - script. - - if (someVar) - someMultiLineScriptFunction(); - else { - - console.log('Hello from Jade!'); - } \ No newline at end of file diff --git a/tests/views/all-features/mixins.jade b/tests/views/all-features/mixins.jade deleted file mode 100644 index d5c72db..0000000 --- a/tests/views/all-features/mixins.jade +++ /dev/null @@ -1,32 +0,0 @@ - -mixin some-button(label) - p The following button is from the mixin some-button - button(type='submit')= $label - -mixin some-input(label) - p The following button is from the mixin some-input - input(type='text', value=$label) - -mixin some-nested-mixin - +some-button('Nested Button 1') - +some-button('Nested Button 2') - if block - block - -mixin some-uncalled-mixin - h2 This mixin is never called - p ...so it shouldnt compile! - -append content - - h1 Mixins - - +some-button('Button 1') - +some-button('Button 2') - - +some-input('Input 1') - +some-input('Input 2') - - +some-nested-mixin - h2 This is block content - p There should be two Nested buttons above here \ No newline at end of file diff --git a/tests/views/all-features/navigation.jade b/tests/views/all-features/navigation.jade deleted file mode 100644 index 128112d..0000000 --- a/tests/views/all-features/navigation.jade +++ /dev/null @@ -1,9 +0,0 @@ - - -p This navigation is from all-features/navigation.jade -nav - ul - li: a(href='#') Start - li: a(href='#') Some Sub Page - li: a(href='#') Some other sub page - li: a(href='#') Some very othe sub page \ No newline at end of file diff --git a/tests/views/index.jade b/tests/views/index.jade deleted file mode 100644 index 3b53c96..0000000 --- a/tests/views/index.jade +++ /dev/null @@ -1,12 +0,0 @@ - - - - - -case 'abc' - default: a - d: e - when 'a': a(b) - c: d - when 'c': b(a) - d: c \ No newline at end of file diff --git a/tests/views/layout-basic.jade b/tests/views/layout-basic.jade deleted file mode 100644 index e8b826d..0000000 --- a/tests/views/layout-basic.jade +++ /dev/null @@ -1,13 +0,0 @@ - -if $xml - doctype xml -else - doctype 5 -html(lang='en') - head - meta(charset='utf-8') - title My Website Title - - body - - block content \ No newline at end of file diff --git a/tests/views/some-include.jade b/tests/views/some-include.jade deleted file mode 100644 index 6fd5f89..0000000 --- a/tests/views/some-include.jade +++ /dev/null @@ -1,10 +0,0 @@ - -h1 I was fucking included -p No really, I was included. - - -table - tr - td Some - td Nested - td Content \ No newline at end of file