Permalink
Browse files

initial commit

git-svn-id: http://svn.twig-project.org/trunk@4 93ef8e89-cb99-4229-a87c-7fa0fa45744b
  • Loading branch information...
1 parent 9511782 commit fd0646e4cfef27c6325da678863764f2f1aaa7f9 fabien committed Oct 7, 2009
Showing with 8,184 additions and 0 deletions.
  1. +9 −0 AUTHORS
  2. +31 −0 LICENSE
  3. +8 −0 README.markdown
  4. +85 −0 doc/01-Introduction.markdown
  5. +692 −0 doc/02-Twig-for-Template-Designers.markdown
  6. +284 −0 doc/03-Twig-for-Developers.markdown
  7. +290 −0 doc/04-Extending-Twig.markdown
  8. +196 −0 doc/05-Hacking-Twig.markdown
  9. +48 −0 lib/Twig/Autoloader.php
  10. +245 −0 lib/Twig/Compiler.php
  11. +36 −0 lib/Twig/CompilerInterface.php
  12. +251 −0 lib/Twig/Environment.php
  13. +21 −0 lib/Twig/Error.php
  14. +397 −0 lib/Twig/ExpressionParser.php
  15. +51 −0 lib/Twig/Extension.php
  16. +113 −0 lib/Twig/Extension/Core.php
  17. +76 −0 lib/Twig/Extension/Escaper.php
  18. +25 −0 lib/Twig/Extension/Macro.php
  19. +88 −0 lib/Twig/Extension/Sandbox.php
  20. +16 −0 lib/Twig/Extension/Set.php
  21. +55 −0 lib/Twig/ExtensionInterface.php
  22. +304 −0 lib/Twig/Lexer.php
  23. +30 −0 lib/Twig/LexerInterface.php
  24. +111 −0 lib/Twig/Loader.php
  25. +41 −0 lib/Twig/Loader/Array.php
  26. +56 −0 lib/Twig/Loader/Filesystem.php
  27. +34 −0 lib/Twig/Loader/String.php
  28. +29 −0 lib/Twig/LoaderInterface.php
  29. +47 −0 lib/Twig/Node.php
  30. +55 −0 lib/Twig/Node/AutoEscape.php
  31. +88 −0 lib/Twig/Node/Block.php
  32. +47 −0 lib/Twig/Node/BlockReference.php
  33. +45 −0 lib/Twig/Node/Call.php
  34. +22 −0 lib/Twig/Node/Expression.php
  35. +19 −0 lib/Twig/Node/Expression/AssignName.php
  36. +61 −0 lib/Twig/Node/Expression/Binary.php
  37. +18 −0 lib/Twig/Node/Expression/Binary/Add.php
  38. +18 −0 lib/Twig/Node/Expression/Binary/And.php
  39. +18 −0 lib/Twig/Node/Expression/Binary/Concat.php
  40. +18 −0 lib/Twig/Node/Expression/Binary/Div.php
  41. +18 −0 lib/Twig/Node/Expression/Binary/Mod.php
  42. +18 −0 lib/Twig/Node/Expression/Binary/Mul.php
  43. +18 −0 lib/Twig/Node/Expression/Binary/Or.php
  44. +18 −0 lib/Twig/Node/Expression/Binary/Sub.php
  45. +57 −0 lib/Twig/Node/Expression/Compare.php
  46. +38 −0 lib/Twig/Node/Expression/Conditional.php
  47. +36 −0 lib/Twig/Node/Expression/Constant.php
  48. +114 −0 lib/Twig/Node/Expression/Filter.php
  49. +56 −0 lib/Twig/Node/Expression/GetAttr.php
  50. +36 −0 lib/Twig/Node/Expression/Name.php
  51. +44 −0 lib/Twig/Node/Expression/Unary.php
  52. +18 −0 lib/Twig/Node/Expression/Unary/Neg.php
  53. +18 −0 lib/Twig/Node/Expression/Unary/Not.php
  54. +18 −0 lib/Twig/Node/Expression/Unary/Pos.php
  55. +55 −0 lib/Twig/Node/Filter.php
  56. +102 −0 lib/Twig/Node/For.php
  57. +103 −0 lib/Twig/Node/If.php
  58. +73 −0 lib/Twig/Node/Include.php
  59. +55 −0 lib/Twig/Node/Macro.php
  60. +178 −0 lib/Twig/Node/Module.php
  61. +42 −0 lib/Twig/Node/Parent.php
  62. +66 −0 lib/Twig/Node/Print.php
  63. +27 −0 lib/Twig/Node/Set.php
  64. +49 −0 lib/Twig/Node/Text.php
  65. +62 −0 lib/Twig/NodeList.php
  66. +30 −0 lib/Twig/NodeListInterface.php
  67. +42 −0 lib/Twig/NodeTransformer.php
  68. +39 −0 lib/Twig/NodeTransformer/Chain.php
  69. +84 −0 lib/Twig/NodeTransformer/Escaper.php
  70. +68 −0 lib/Twig/NodeTransformer/Filter.php
  71. +58 −0 lib/Twig/NodeTransformer/Sandbox.php
  72. +213 −0 lib/Twig/Parser.php
  73. +29 −0 lib/Twig/ParserInterface.php
  74. +22 −0 lib/Twig/RuntimeError.php
  75. +21 −0 lib/Twig/Sandbox/SecurityError.php
  76. +84 −0 lib/Twig/Sandbox/SecurityPolicy.php
  77. +24 −0 lib/Twig/Sandbox/SecurityPolicyInterface.php
  78. +51 −0 lib/Twig/SyntaxError.php
  79. +69 −0 lib/Twig/Template.php
  80. +18 −0 lib/Twig/TemplateInterface.php
  81. +111 −0 lib/Twig/Token.php
  82. +24 −0 lib/Twig/TokenParser.php
  83. +38 −0 lib/Twig/TokenParser/AutoEscape.php
  84. +52 −0 lib/Twig/TokenParser/Block.php
  85. +30 −0 lib/Twig/TokenParser/Call.php
  86. +31 −0 lib/Twig/TokenParser/Display.php
  87. +30 −0 lib/Twig/TokenParser/Extends.php
  88. +34 −0 lib/Twig/TokenParser/Filter.php
  89. +50 −0 lib/Twig/TokenParser/For.php
  90. +65 −0 lib/Twig/TokenParser/If.php
  91. +34 −0 lib/Twig/TokenParser/Include.php
  92. +37 −0 lib/Twig/TokenParser/Macro.php
  93. +29 −0 lib/Twig/TokenParser/Parent.php
  94. +20 −0 lib/Twig/TokenParser/Set.php
  95. +139 −0 lib/Twig/TokenStream.php
  96. +158 −0 lib/Twig/runtime.php
  97. +26 −0 lib/Twig/runtime_escaper.php
  98. +123 −0 lib/Twig/runtime_for.php
  99. +44 −0 test/bin/coverage.php
  100. +28 −0 test/bin/prove.php
  101. +40 −0 test/fixtures/expressions/binary.test
  102. +16 −0 test/fixtures/expressions/comparison.test
  103. +8 −0 test/fixtures/expressions/grouping.test
  104. +14 −0 test/fixtures/expressions/ternary_operator.test
  105. +10 −0 test/fixtures/expressions/unary.test
  106. +10 −0 test/fixtures/filters/date.test
  107. +10 −0 test/fixtures/filters/default.test
  108. +9 −0 test/fixtures/filters/even.test
  109. +8 −0 test/fixtures/filters/format.test
  110. +10 −0 test/fixtures/filters/length.test
  111. +10 −0 test/fixtures/filters/odd.test
  112. +10 −0 test/fixtures/filters/sort.test
  113. +22 −0 test/fixtures/tags/autoescape/basic.test
  114. +10 −0 test/fixtures/tags/autoescape/double_escaping.test
  115. +26 −0 test/fixtures/tags/autoescape/nested.test
  116. +12 −0 test/fixtures/tags/autoescape/safe.test
  117. +10 −0 test/fixtures/tags/filter/basic.test
  118. +16 −0 test/fixtures/tags/filter/nested.test
  119. +13 −0 test/fixtures/tags/filter/with_for_tag.test
  120. +29 −0 test/fixtures/tags/filter/with_if_tag.test
  121. +18 −0 test/fixtures/tags/for/context.test
  122. +21 −0 test/fixtures/tags/for/else.test
  123. +11 −0 test/fixtures/tags/for/keys.test
  124. +11 −0 test/fixtures/tags/for/keys_and_values.test
  125. +19 −0 test/fixtures/tags/for/loop_context.test
  126. +10 −0 test/fixtures/tags/for/loop_context_local.test
  127. +17 −0 test/fixtures/tags/for/nested_else.test
  128. +34 −0 test/fixtures/tags/for/objects.test
  129. +18 −0 test/fixtures/tags/for/recursive.test
  130. +11 −0 test/fixtures/tags/for/values.test
  131. +22 −0 test/fixtures/tags/if/basic.test
  132. +22 −0 test/fixtures/tags/if/expression.test
  133. +16 −0 test/fixtures/tags/include/basic.test
  134. +16 −0 test/fixtures/tags/include/expression.test
  135. +14 −0 test/fixtures/tags/inheritance/basic.test
  136. +12 −0 test/fixtures/tags/inheritance/parent.test
  137. +43 −0 test/lib/Twig_Loader_Var.php
  138. +27 −0 test/unit/Twig/AutoloaderTest.php
  139. +127 −0 test/unit/Twig/Extension/Sandbox.php
  140. +70 −0 test/unit/integrationTest.php
View
@@ -0,0 +1,9 @@
+Twig is written and maintained by the Twig Team:
+
+Lead Developer:
+
+- Fabien Potencier <fabien.potencier@symfony-project.org>
+
+Project Founder:
+
+- Armin Ronacher <armin.ronacher@active-4.com>
View
31 LICENSE
@@ -0,0 +1,31 @@
+Copyright (c) 2009 by the Twig Team, see AUTHORS for more details.
+
+Some rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * The names of the contributors may not be used to endorse or
+ promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
@@ -0,0 +1,8 @@
+Twig, the flexible, fast, and secure template language for PHP
+==============================================================
+
+Twig is a template language for PHP, released under the new BSD license (code
+and documentation).
+
+Twig uses a syntax similar to the Django and Jinja template languages which
+inspired the Twig runtime environment.
@@ -0,0 +1,85 @@
+Introduction
+============
+
+This is the documentation for Twig, the flexible, fast, and secure template
+language for PHP.
+
+If you have any exposure to other text-based template languages, such as
+Smarty, Django, or Jinja, you should feel right at home with Twig. It's both
+designer and developer friendly by sticking to PHP's principles and adding
+functionality useful for templating environments.
+
+The key-features are...
+
+ * *Fast*: Twig compiles templates down to plain optimized PHP code. The
+ overhead compared to regular PHP code was reduced to the very minimum.
+
+ * *Secure*: Twig has a sandbox mode to evaluate untrusted template code. This
+ allows Twig to be used as a templating language for applications where
+ users may modify the template design.
+
+ * *Flexible*: Twig is powered by a flexible lexer and parser. This allows the
+ developer to define its own custom tags and filters, and create its own
+ DSL.
+
+Prerequisites
+-------------
+
+Twig needs at least **PHP 5.2.4** to run.
+
+Installation
+------------
+
+You have multiple ways to install Twig. If you are unsure what to do, go with
+the tarball.
+
+### From the tarball release
+
+ 1. Download the most recent tarball from the [download page](http://www.twig-project.org/installation)
+ 2. Unpack the tarball
+ 3. Move the files somewhere in your project
+
+### Installing the development version
+
+ 1. Install Subversion
+ 2. `svn co http://svn.twig-project.org/trunk/ twig`
+
+Basic API Usage
+---------------
+
+This section gives you a brief introduction to the PHP API for Twig.
+
+The first step to use Twig is to register its autoloader:
+
+ [php]
+ require_once '/path/to/lib/Twig/Autoloader.php';
+ Twig_Autoloader::register();
+
+Replace the `/path/to/lib/` path with the path you used for Twig installation.
+
+>**NOTE**
+>Twig follows the PEAR convention names for its classes, which means you can
+>easily integrate Twig classes loading in your own autoloader.
+
+ [php]
+ $loader = new Twig_Loader_String();
+ $twig = new Twig_Environment($loader);
+
+ $template = $twig->loadTemplate('Hello {{ name }}!');
+
+ $template->display(array('name' => 'Fabien'));
+
+Twig uses a loader (`Twig_Loader_String`) to locate templates, and an
+environment (`Twig_Environment`) to store the configuration.
+
+The `loadTemplate()` method uses the loader to locate and load the template
+and returns a template object (`Twig_Template`) which is suitable for
+rendering with the `display()` method.
+
+Twig also comes with a filesystem loader:
+
+ [php]
+ $loader = new Twig_Loader_Filesystem('/path/to/templates');
+ $twig = new Twig_Environment($loader);
+
+ $template = $twig->loadTemplate('index.html');
Oops, something went wrong.

0 comments on commit fd0646e

Please sign in to comment.