فهرست منبع

Add an example for anchored dot notation.

Justin Hileman 8 سال پیش
والد
کامیت
14ff48584a

+ 55 - 0
test/fixtures/examples/anchored_dot_notation/AnchoredDotNotation.php

@@ -0,0 +1,55 @@
+<?php
+
+/*
+ * This file is part of Mustache.php.
+ *
+ * (c) 2010-2017 Justin Hileman
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+class AnchoredDotNotation
+{
+    public $genres = array(
+        array(
+            'name' => 'Punk',
+            'subgenres' => array(
+                array(
+                    'name' => 'Hardcore',
+                    'subgenres' => array(
+                        array(
+                            'name' => 'First wave of black metal',
+                            'subgenres' => array(
+                                array('name' => 'Norwegian black metal'),
+                                array(
+                                    'name' => 'Death metal',
+                                    'subgenres' => array(
+                                        array(
+                                            'name' => 'Swedish death metal',
+                                            'subgenres' => array(
+                                                array('name' => 'New wave of American metal'),
+                                            ),
+                                        ),
+                                    ),
+                                ),
+                            ),
+                        ),
+                        array(
+                            'name' => 'Thrash metal',
+                            'subgenres' => array(
+                                array('name' => 'Grindcore'),
+                                array(
+                                    'name' => 'Metalcore',
+                                    'subgenres' => array(
+                                        array('name' => 'Nu metal'),
+                                    ),
+                                ),
+                            ),
+                        ),
+                    ),
+                ),
+            ),
+        ),
+    );
+}

+ 4 - 0
test/fixtures/examples/anchored_dot_notation/anchored_dot_notation.mustache

@@ -0,0 +1,4 @@
+{{% ANCHORED-DOT }}
+{{# genres }}
+{{> genre }}
+{{/ genres }}

+ 11 - 0
test/fixtures/examples/anchored_dot_notation/anchored_dot_notation.txt

@@ -0,0 +1,11 @@
+ - Punk
+    - Hardcore
+       - First wave of black metal
+          - Norwegian black metal
+          - Death metal
+             - Swedish death metal
+                - New wave of American metal
+       - Thrash metal
+          - Grindcore
+          - Metalcore
+             - Nu metal

+ 5 - 0
test/fixtures/examples/anchored_dot_notation/partials/genre.mustache

@@ -0,0 +1,5 @@
+{{% ANCHORED-DOT }}
+ - {{ name }}
+{{# .subgenres }}
+   {{> genre }}
+{{/ .subgenres }}