Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit ad11834994e2716733281f3a8dacdebfce7c279b @harrydeluxe harrydeluxe committed Feb 9, 2011
@@ -0,0 +1,19 @@
+Copyright (c) 2006 Mateo Murphy
+
+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.
@@ -0,0 +1,178 @@
+<?php
+/**
+ * Liquid for PHP
+ *
+ * @package Liquid
+ * @copyright Copyright (c) 2011 Harald Hanek,
+ * fork of php-liquid (c) 2006 Mateo Murphy,
+ * based on Liquid for Ruby (c) 2006 Tobias Luetke
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+
+/**
+ * The method is called on objects when resolving variables to see
+ * if a given property exists
+ *
+ */
+define('LIQUID_HAS_PROPERTY_METHOD', 'field_exists');
+
+/**
+ * This method is called on object when resolving variables when
+ * a given property exists
+ *
+ */
+define('LIQUID_GET_PROPERTY_METHOD', 'get');
+
+/**
+ * Seperator between filters
+ *
+ */
+define('LIQUID_FILTER_SEPERATOR', '\|');
+
+/**
+ * Seperator for arguments
+ *
+ */
+define('LIQUID_ARGUMENT_SPERATOR', ',');
+
+/**
+ * Seperator for argument names and values
+ *
+ */
+define('LIQUID_FILTER_ARGUMENT_SEPERATOR', ':');
+
+/**
+ * Seperator for variable attributes
+ *
+ */
+define('LIQUID_VARIABLE_ATTRIBUTE_SEPERATOR', '.');
+
+/**
+ * Suffix fuer include dateien
+ *
+ */
+defined('LIQUID_INCLUDE_SUFFIX') or define('LIQUID_INCLUDE_SUFFIX', 'tpl');
+
+/**
+ * Tag start
+ *
+ */
+define('LIQUID_TAG_START', '{%');
+
+/**
+ * Tag end
+ *
+ */
+define('LIQUID_TAG_END', '%}');
+
+/**
+ * Variable start
+ *
+ */
+define('LIQUID_VARIABLE_START', '{{');
+
+/**
+ * Variable end
+ *
+ */
+define('LIQUID_VARIABLE_END', '}}');
+
+/**
+ * The characters allowed in a variable
+ *
+ */
+define('LIQUID_ALLOWED_VARIABLE_CHARS', '[a-zA-Z_.-]');
+
+/**
+ * Regex for quoted fragments
+ *
+ */
+define('LIQUID_QUOTED_FRAGMENT', '"[^"]+"|\'[^\']+\'|[^\s,|]+');
+
+/**
+ * Regex for recongnizing tab attributes
+ *
+ */
+define('LIQUID_TAG_ATTRIBUTES', '/(\w+)\s*\:\s*('.LIQUID_QUOTED_FRAGMENT.')/');
+
+/**
+ * Regex used to split tokenss
+ *
+ */
+define('LIQUID_TOKENIZATION_REGEXP', '/('.LIQUID_TAG_START.'.*?'.LIQUID_TAG_END.'|'.LIQUID_VARIABLE_START.'.*?'.LIQUID_VARIABLE_END.')/');
+
+
+defined('LIQUID_PATH') or define('LIQUID_PATH',dirname(__FILE__));
+
+
+class Liquid
+{
+ /**
+ * Flatten a multidimensional array into a single array. Does not maintain keys.
+ *
+ * @param array $array
+ * @return array
+ */
+ public static function array_flatten($array)
+ {
+ $return = array();
+
+ foreach($array as $element)
+ {
+ if(is_array($element))
+ {
+ $return = array_merge($return, self::array_flatten($element));
+ }
+ else
+ {
+ $return[] = $element;
+ }
+ }
+ return $return;
+ }
+
+
+ /**
+ * Class autoload loader.
+ * This method is provided to be invoked within an __autoload() magic method.
+ * @param string $className class name
+ * @return boolean whether the class has been loaded successfully
+ */
+ public static function autoload($className)
+ {
+ // use include so that the error PHP file may appear
+ if(isset(self::$_coreClasses[$className]))
+ include(LIQUID_PATH.self::$_coreClasses[$className]);
+ //include_once(LIQUID_PATH.self::$_coreClasses[$className]);
+ return true;
+ }
+
+
+ private static $_coreClasses = array(
+ 'LiquidException' => '/lib/LiquidException.class.php',
+ 'LiquidRegexp' => '/lib/LiquidRegexp.class.php',
+ 'LiquidBlock' => '/lib/LiquidBlock.class.php',
+ 'LiquidContext' => '/lib/LiquidContext.class.php',
+ 'LiquidDocument' => '/lib/LiquidDocument.class.php',
+ 'LiquidDrop' => '/lib/LiquidDrop.class.php',
+ 'LiquidBlankFileSystem' => '/lib/LiquidBlankFileSystem.class.php',
+ 'LiquidLocalFileSystem' => '/lib/LiquidLocalFileSystem.class.php',
+ 'LiquidFilterbank' => '/lib/LiquidFilterbank.class.php',
+ 'TableRowLiquidTag' => '/lib/Tag/TableRowLiquidTag.class.php',
+ 'LiquidDecisionBlock' => '/lib/Tag/LiquidDecisionBlock.class.php',
+ 'IncludeLiquidTag' => '/lib/Tag/IncludeLiquidTag.class.php',
+ 'CaseLiquidTag' => '/lib/Tag/CaseLiquidTag.class.php',
+ 'AssignLiquidTag' => '/lib/Tag/AssignLiquidTag.class.php',
+ 'CommentLiquidTag' => '/lib/Tag/CommentLiquidTag.class.php',
+ 'CaptureLiquidTag' => '/lib/Tag/CaptureLiquidTag.class.php',
+ 'CycleLiquidTag' => '/lib/Tag/CycleLiquidTag.class.php',
+ 'ForLiquidTag' => '/lib/Tag/ForLiquidTag.class.php',
+ 'IfLiquidTag' => '/lib/Tag/IfLiquidTag.class.php',
+ 'LiquidStandardFilters' => '/lib/LiquidStandardFilters.class.php',
+ 'LiquidTag' => '/lib/LiquidTag.class.php',
+ 'LiquidTemplate' => '/lib/LiquidTemplate.class.php',
+ 'LiquidVariable' => '/lib/LiquidVariable.class.php'
+ );
+}
+
+spl_autoload_register(array('Liquid', 'autoload'));
@@ -0,0 +1,22 @@
+h1. Liquid template engine for PHP
+
+Liquid is a PHP port of the Liquid template engine for Ruby, which was
+written by Tobias Lutke. Although there are many other templating engines
+for PHP, including Smarty (from which Liquid was partially inspired), Liquid
+had some advantages that made porting worthwhile:
+
+* Default syntax that is usable in any type of document, not just html,
+ without need for escaping.
+* 100% secure, no possibility of embedding PHP code.
+* Clean OO design, rather than the mix of OO and procedural found
+ in other templating engines.
+* Seperate compiling and rendering stages for impreoved performance.
+* 100% Markup compatibility with a Ruby templating engine, making templates
+ usable for either.
+
+For more information on Liquid, visit: http://www.liquidmarkup.org
+
+h1. Fork Notes
+
+This fork is based on php-liquid by Mateo Murphy. The original library is still hosted at: http://code.google.com/p/php-liquid/
+
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Liquid for PHP
+ *
+ * @package Liquid
+ * @copyright Copyright (c) 2011 Harald Hanek,
+ * fork of php-liquid (c) 2006 Mateo Murphy,
+ * based on Liquid for Ruby (c) 2006 Tobias Luetke
+ * @license http://www.opensource.org/licenses/mit-license.php
+ */
+
+
+/**
+ * A Liquid file system is way to let your templates retrieve other templates for use with the include tag.
+ *
+ * You can implement subclasses that retrieve templates from the database, from the file system using a different
+ * path structure, you can provide them as hard-coded inline strings, or any manner that you see fit.
+ *
+ * You can add additional instance variables, arguments, or methods as needed
+ *
+ * @package Liquid
+ */
+class LiquidBlankFileSystem
+{
+ /**
+ * Retrieve a template file
+ *
+ * @param string $template_path
+ */
+ function read_template_file($template_path)
+ {
+ throw new LiquidException("This liquid context does not allow includes.");
+ }
+
+}
Oops, something went wrong.

0 comments on commit ad11834

Please sign in to comment.