From: Andrey Kutejko Date: Sun, 8 Feb 2015 10:21:08 +0000 (+0200) Subject: initial commit X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=0011a9adaa5ff903e2fb1be6f606870108fde97b;p=ipf-legacy-template.git initial commit --- 0011a9adaa5ff903e2fb1be6f606870108fde97b diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4acdc48 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +/vendor + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..0e157a8 --- /dev/null +++ b/composer.json @@ -0,0 +1,25 @@ +{ + "name": "andy128k/ipf-legacy-template", + "authors": [ + { + "name": "Andrey Kutejko", + "email": "andy128k@gmail.com" + } + ], + "repositories": [ + { + "type": "composer", + "url": "http://packages.andy128k.net/php/" + } + ], + "autoload": { + "classmap" : ["src"] + }, + "require": { + "andy128k/ipf-template": "0.1.*@dev" + }, + "suggest": { + "andy128k/ipf": "Web Framework" + } +} + diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..0df18d8 --- /dev/null +++ b/composer.lock @@ -0,0 +1,53 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "7bc61fe1f500d3685ddc2c9ae301e6bf", + "packages": [ + { + "name": "andy128k/ipf-template", + "version": "0.1.x-dev", + "source": { + "type": "git", + "url": "git://git.andy128k.net/ipf-template.git", + "reference": "6b0ee73b0df4689317a975f6c09ecc01fdddad6d" + }, + "require-dev": { + "phpunit/phpunit": "4.4.*" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib" + ] + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Litovchenko", + "email": "alex.litovchenko@gmail.com" + }, + { + "name": "Andrey Kutejko", + "email": "andy128k@gmail.com" + } + ], + "description": "Template Engine extracted from IPF Web Framework", + "time": "2015-01-11 10:49:36" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": { + "andy128k/ipf-template": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/src/shortcuts.php b/src/shortcuts.php new file mode 100644 index 0000000..b5449e3 --- /dev/null +++ b/src/shortcuts.php @@ -0,0 +1,62 @@ +render(new IPF_Template_Context($context)); + } + + private static $defaultEnvironment = null; + + public static function getDefaultTemplateEnvironment() + { + if (!self::$defaultEnvironment) + self::$defaultEnvironment = self::createEnvironment(); + return self::$defaultEnvironment; + } + + private static function createEnvironment() + { + $e = new IPF_Template_Environment_FileSystem; + + $e->cache = IPF::get('tmp'); + $e->debug = IPF::get('debug'); + + $e->folders = IPF_Project_Template::templateDirs(); + + $e->tags['url'] = 'IPF_Template_Tag_Url'; + $e->tags['params'] = 'IPF_Template_Tag_Params'; + // extra tags + $e->tags = array_merge(IPF::get('template_tags', array()), $e->tags); + + // extra modifiers + $e->modifiers = array_merge(IPF::get('template_modifiers', array()), $e->modifiers); + + return $e; + } +} + +class IPF_Template_Tag_Url extends IPF_Template_Tag +{ + function start() + { + echo IPF_Project_Template::urlTag(func_get_args()); + } +} + +class IPF_Template_Tag_Params extends IPF_Template_Tag +{ + function start() + { + echo IPF_Project_Template::paramsTag(func_get_args()); + } +} +