PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / lib / Mustache / LambdaHelper.php

LambdaHelper.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.3, at assets/lib/Mustache/LambdaHelper.php

77 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of Mustache.php.
5 *
6 * (c) 2010-2017 Justin Hileman
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 /**
13 * Mustache Lambda Helper.
14 *
15 * Passed as the second argument to section lambdas (higher order sections),
16 * giving them access to a `render` method for rendering a string with the
17 * current context.
18 */
19 class Mustache_LambdaHelper
20 {
21 private $mustache;
22 private $context;
23 private $delims;
24
25 /**
26 * Mustache Lambda Helper constructor.
27 *
28 * @param Mustache_Engine $mustache Mustache engine instance
29 * @param Mustache_Context $context Rendering context
30 * @param string $delims Optional custom delimiters, in the format `{{= <% %> =}}`. (default: null)
31 */
32 public function __construct(Mustache_Engine $mustache, Mustache_Context $context, $delims = null)
33 {
34 $this->mustache = $mustache;
35 $this->context = $context;
36 $this->delims = $delims;
37 }
38
39 /**
40 * Render a string as a Mustache template with the current rendering context.
41 *
42 * @param string $string
43 *
44 * @return string Rendered template
45 */
46 public function render($string)
47 {
48 return $this->mustache
49 ->loadLambda((string) $string, $this->delims)
50 ->renderInternal($this->context);
51 }
52
53 /**
54 * Render a string as a Mustache template with the current rendering context.
55 *
56 * @param string $string
57 *
58 * @return string Rendered template
59 */
60 public function __invoke($string)
61 {
62 return $this->render($string);
63 }
64
65 /**
66 * Get a Lambda Helper with custom delimiters.
67 *
68 * @param string $delims Custom delimiters, in the format `{{= <% %> =}}`
69 *
70 * @return Mustache_LambdaHelper
71 */
72 public function withDelimiters($delims)
73 {
74 return new self($this->mustache, $this->context, $delims);
75 }
76 }
77