From c1cdea7bc530aaa3f5ab9842651c0890bd141d2e Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 11 Jul 2010 23:17:14 -0400 Subject: [PATCH] Added documentation for IMPLICIT-ITERATOR and DOT-NOTATION pragmas. --- Mustache.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Mustache.php b/Mustache.php index d24b632..f87696d 100644 --- a/Mustache.php +++ b/Mustache.php @@ -33,7 +33,44 @@ class Mustache { // Override charset passed to htmlentities() and htmlspecialchars(). Defaults to UTF-8. protected $_charset = 'UTF-8'; + /** + * Pragmas are macro-like directives that, when invoked, change the behavior or + * syntax of Mustache. + * + * They should be considered extremely experimental. Most likely their implementation + * will change in the future. + */ + + /** + * The {{%DOT-NOTATION}} pragma allows context traversal via dots. Given the following context: + * + * $context = array('foo' => array('bar' => array('baz' => 'qux'))); + * + * One could access nested properties using dot notation: + * + * {{%DOT-NOTATION}}{{foo.bar.baz}} + * + * Which would render as `qux`. + */ const PRAGMA_DOT_NOTATION = 'DOT-NOTATION'; + + /** + * The {{%IMPLICIT-ITERATOR}} pragma allows access to non-associative array data in an + * iterable section: + * + * $context = array('items' => array('foo', 'bar', 'baz')); + * + * With this template: + * + * {{%IMPLICIT-ITERATOR}}{{#items}}{{.}}{{/items}} + * + * Would render as `foobarbaz`. + * + * {{%IMPLICIT-ITERATOR}} accepts an optional 'iterator' argument which allows implicit + * iterator tags other than {{.}} ... + * + * {{%IMPLICIT-ITERATOR iterator=i}}{{#items}}{{i}}{{/items}} + */ const PRAGMA_IMPLICIT_ITERATOR = 'IMPLICIT-ITERATOR'; /**