From 88fc338b55118d42d074592127d06eae2f6269e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D0=B5=D0=B4=D0=BE=D1=80=20=D0=9F=D0=BE=D0=B4=D0=BB?= =?UTF-8?q?=D0=B5=D1=81=D0=BD=D0=BE=D0=B2?= Date: Tue, 1 Dec 2015 15:01:10 +0300 Subject: [PATCH] initial commmit --- example.php | 9 +++++++++ index.html | 21 +++++++++++++++++++++ klein.php | 27 +++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 example.php create mode 100644 index.html create mode 100644 klein.php diff --git a/example.php b/example.php new file mode 100644 index 0000000..15cf792 --- /dev/null +++ b/example.php @@ -0,0 +1,9 @@ + array('style.css'), + 'script' => array('script.js'), + 'content' => 'test' +)); \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..a8f521b --- /dev/null +++ b/index.html @@ -0,0 +1,21 @@ + + + + + + {% for file in style %} + + {% endfor %} + + + {% if content %} + {{ content }} + {% endif %} + + {% for file in script %} + + {% endfor %} + + + + diff --git a/klein.php b/klein.php new file mode 100644 index 0000000..8e51bf2 --- /dev/null +++ b/klein.php @@ -0,0 +1,27 @@ + "", + "/{%\s*if\s+(\w+)\s*%}/" => "", + "/{%\s*block\s+(\w+)\s*%}/" => "", + "/{%\s*endblock\s*%}/" => "", + "/{%\s*endfor\s*%}/" => "", + "/{%\s*endif\s*%}/" => "", + "/{{\s*(\w+)\s*}}/" => "", + ); + + $result = $data; + foreach($pattern as $key => $value) { + $result = preg_replace($key, $value, $result); + } + + extract($vars); + + ob_start(); + eval(" ?>".$result."