Skip to content

Commit 9b57ea6

Browse files
committed
Remove option to preprocess partials
1 parent 6b9d0df commit 9b57ea6

File tree

5 files changed

+3
-69
lines changed

5 files changed

+3
-69
lines changed

README.md

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
LightnCandy
22
===========
33

4-
⚡🍭 An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ).
4+
An extremely fast PHP implementation of [Handlebars](https://handlebarsjs.com/).
55

66
Features
77
--------
88

99
* Compile template to **pure PHP** code. Examples:
1010
* <a href="https://github.com/zordius/HandlebarsTest/blob/master/fixture/001-simple-vars.tmpl">Template A</a> generated <a href="https://github.com/zordius/HandlebarsTest/blob/master/fixture/001-simple-vars.php">PHP A</a>
1111
* <a href="https://github.com/zordius/HandlebarsTest/blob/master/fixture/016-hb-eachthis.tmpl">Template B</a> generated <a href="https://github.com/zordius/HandlebarsTest/blob/master/fixture/016-hb-eachthis.php">PHP B</a>
12-
* **FAST!**
13-
* Runs 2~7 times faster than <a href="https://github.com/bobthecow/mustache.php">mustache.php</a> (Justin Hileman/bobthecow implementation).
14-
* Runs 2~7 times faster than <a href="https://github.com/dingram/mustache-php">mustache-php</a> (Dave Ingram implementation).
15-
* Runs 10~50 times faster than <a href="https://github.com/XaminProject/handlebars.php">handlebars.php</a>.
16-
* Detail performance test reports can be found <a href="https://github.com/zordius/HandlebarsTest">here</a>, go http://zordius.github.io/HandlebarsTest/ to see charts.
17-
* **SMALL!** all PHP files in 189K
1812
* **ROBUST!**
1913
* Supports almost all <a href="https://github.com/jbboehr/handlebars-spec">handlebars.js spec</a>
2014
* Output <a href="https://github.com/zordius/HandlebarsTest/blob/master/FEATURES.md">SAME</a> with <a href="https://github.com/wycats/handlebars.js">handlebars.js</a>
@@ -66,7 +60,7 @@ LightnCandy::compile($template, array(
6660
* <a href="https://zordius.github.io/HandlebarsCookbook/LC-FLAG_NOESCAPE.html">FLAG_NOESCAPE</a>
6761
* <a href="https://zordius.github.io/HandlebarsCookbook/LC-FLAG_PARTIALNEWCONTEXT.html">FLAG_PARTIALNEWCONTEXT</a>
6862
* `FLAG_IGNORESTANDALONE` : prevent standalone detection on `{{#foo}}`, `{{/foo}}` or `{{^}}`, the behavior is same with handlebars.js ignoreStandalone compile time option.
69-
* `FLAG_PREVENTINDENT` : align partial indent behavior with mustache specification. This is same with handlebars.js preventIndent copmile time option.
63+
* `FLAG_PREVENTINDENT` : Prevent indented partial-call from indenting the entire partial output by the same amount. Same as the Handlebars.js `preventIndent` compile option.
7064

7165
**PHP**
7266
* <a href="https://zordius.github.io/HandlebarsCookbook/LC-FLAG_RUNTIMEPARTIAL.html">FLAG_RUNTIMEPARTIAL</a>
@@ -288,21 +282,6 @@ Here are the list of LightnCandy\Runtime debug options for render function:
288282
* `DEBUG_TAGS_ANSI` : turn the return value of render function into normalized mustache tags with ANSI color
289283
* `DEBUG_TAGS_HTML` : turn the return value of render function into normalized mustache tags with HTML comments
290284

291-
Preprocess Partials
292-
-------------------
293-
294-
If you want to do extra process before the partial be compiled, you may use `prepartial` when `compile()`. For example, this sample adds HTML comments to identify the partial by the name:
295-
296-
```php
297-
$php = LightnCandy::compile($template, array(
298-
'prepartial' => function ($context, $template, $name) {
299-
return "<!-- partial start: $name -->$template<!-- partial end: $name -->";
300-
}
301-
));
302-
```
303-
304-
You may also extend <a href="https://zordius.github.io/lightncandy/class-LightnCandy.Partial.html">LightnCandy\Partial</a> by override the <a href="https://zordius.github.io/lightncandy/class-LightnCandy.Partial.html#_prePartial">prePartial()</a> static method to turn your preprocess into a built-in feature.
305-
306285
Customize Render Function
307286
-------------------------
308287

@@ -337,11 +316,9 @@ Detail Feature list
337316
Go http://handlebarsjs.com/ to see more feature description about handlebars.js. All features align with it.
338317

339318
* Exact same CR/LF behavior with handlebars.js
340-
* Exact same CR/LF bahavior with mustache spec
341319
* Exact same 'true' or 'false' output with handlebars.js
342320
* Exact same '[object Object]' output or join(',' array) output with handlebars.js
343321
* Can place heading/tailing space, tab, CR/LF inside `{{ var }}` or `{{{ var }}}`
344-
* Indent behavior of the partial same with mustache spec
345322
* `{{{value}}}` or `{{&value}}` : raw variable
346323
* true as 'true'
347324
* false as 'false' (require `FLAG_TRUE`)

build/gen_test.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
genTestForClass('Expression');
1010
genTestForClass('LightnCandy');
1111
genTestForClass('Parser');
12-
genTestForClass('Partial');
1312
genTestForClass('Runtime');
1413
genTestForClass('SafeString');
1514
genTestForClass('Token');

src/Context.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public static function create($options)
103103
'inlinepartial' => array(),
104104
'helpers' => array(),
105105
'renderex' => isset($options['renderex']) ? $options['renderex'] : '',
106-
'prepartial' => (isset($options['prepartial']) && is_callable($options['prepartial'])) ? $options['prepartial'] : false,
107106
'safestring' => '\\LightnCandy\\SafeString',
108107
'safestringalias' => isset($options['safestring']) ? $options['safestring'] : 'LS',
109108
'rawblock' => false,

src/Partial.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,6 @@ public static function read(&$context, $name)
6868
}
6969
}
7070

71-
/**
72-
* preprocess partial template before it be stored into context
73-
*
74-
* @param array<string,array|string|integer> $context Current context of compiler progress.
75-
* @param string $tmpl partial template
76-
* @param string $name partial name
77-
*
78-
* @return string|null $content processed partial template
79-
*
80-
* @expect 'hey' when input array('prepartial' => false), 'hey', 'haha'
81-
* @expect 'haha-hoho' when input array('prepartial' => function ($cx, $tmpl, $name) {return "$name-$tmpl";}), 'hoho', 'haha'
82-
*/
83-
protected static function prePartial(&$context, $tmpl, &$name)
84-
{
85-
return $context['prepartial'] ? $context['prepartial']($context, $tmpl, $name) : $tmpl;
86-
}
87-
8871
/**
8972
* resolve partial, return the partial content
9073
*
@@ -99,7 +82,7 @@ public static function resolve(&$context, &$name)
9982
$name = "@partial-block{$context['usedFeature']['pblock']}";
10083
}
10184
if (isset($context['partials'][$name])) {
102-
return static::prePartial($context, $context['partials'][$name], $name);
85+
return $context['partials'][$name];
10386
}
10487
}
10588

tests/PartialTest.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)