瀏覽代碼

Merge branch 'release/2.3.1'

Justin Hileman 12 年之前
父節點
當前提交
3ef28e14e3
共有 3 個文件被更改,包括 27 次插入27 次删除
  1. 15 17
      LICENSE
  2. 5 5
      src/Mustache/Engine.php
  3. 7 5
      src/Mustache/Tokenizer.php

+ 15 - 17
LICENSE

@@ -1,22 +1,20 @@
+The MIT License (MIT)
 Copyright (c) 2010 Justin Hileman
 
-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:
+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 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.
+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.

+ 5 - 5
src/Mustache/Engine.php

@@ -23,7 +23,7 @@
  */
 class Mustache_Engine
 {
-    const VERSION        = '2.3.0';
+    const VERSION        = '2.3.1';
     const SPEC_VERSION   = '1.1.2';
 
     const PRAGMA_FILTERS = 'FILTERS';
@@ -155,19 +155,19 @@ class Mustache_Engine
     /**
      * Shortcut 'render' invocation.
      *
-     * Equivalent to calling `$mustache->loadTemplate($template)->render($data);`
+     * Equivalent to calling `$mustache->loadTemplate($template)->render($context);`
      *
      * @see Mustache_Engine::loadTemplate
      * @see Mustache_Template::render
      *
      * @param string $template
-     * @param mixed  $data
+     * @param mixed  $context (default: array())
      *
      * @return string Rendered template
      */
-    public function render($template, $data)
+    public function render($template, $context = array())
     {
-        return $this->loadTemplate($template)->render($data);
+        return $this->loadTemplate($template)->render($context);
     }
 
     /**

+ 7 - 5
src/Mustache/Tokenizer.php

@@ -107,10 +107,11 @@ class Mustache_Tokenizer
                         $this->flushBuffer();
                         $this->state = self::IN_TAG_TYPE;
                     } else {
-                        if ($text[$i] == "\n") {
+                        $char = substr($text, $i, 1);
+                        if ($char == "\n") {
                             $this->filterLine();
                         } else {
-                            $this->buffer .= $text[$i];
+                            $this->buffer .= $char;
                         }
                     }
                     break;
@@ -118,8 +119,9 @@ class Mustache_Tokenizer
                 case self::IN_TAG_TYPE:
 
                     $i += strlen($this->otag) - 1;
-                    if (isset(self::$tagTypes[$text[$i + 1]])) {
-                        $tag = $text[$i + 1];
+                    $char = substr($text, $i + 1, 1);
+                    if (isset(self::$tagTypes[$char])) {
+                        $tag = $char;
                         $this->tagType = $tag;
                     } else {
                         $tag = null;
@@ -166,7 +168,7 @@ class Mustache_Tokenizer
                             }
                         }
                     } else {
-                        $this->buffer .= $text[$i];
+                        $this->buffer .= substr($text, $i, 1);
                     }
                     break;
             }