@@ -261,12 +261,6 @@ public static CharSequence escapeExpression(final CharSequence input) {
261261 */
262262 private boolean prettyPrint ;
263263
264- /**
265- * If true, given partial blocks are not evaluated when defined but when used.
266- * If false, partial blocks are evaluated when defined and used.
267- */
268- private boolean lazyPartialBlockEvaluation ;
269-
270264 /**
271265 * The helper registry.
272266 */
@@ -321,6 +315,33 @@ public static CharSequence escapeExpression(final CharSequence input) {
321315 /** True, if we want to extend lookup to parent scope. */
322316 private boolean parentScopeResolution = true ;
323317
318+ /**
319+ * If true partial blocks will be evaluated to allow side effects by defining inline
320+ * blocks within the partials blocks.
321+ * Attention: This feature slows down the performance severly if your templates use
322+ * deeply nested partial blocks.
323+ * Handlebars works *much* faster if this feature is set to false.
324+ *
325+ * Example of a feature that is usable when this is set to true:
326+ * <pre>
327+ * {{#> myPartial}}{{#*inline 'myInline'}}Wow!!!{{/inline}}{{/myPartial}}
328+ * </pre>
329+ * With a myPartial.hbs template like this:
330+ * <pre>
331+ * {{> myInline}}
332+ * </pre>
333+ * The text "Wow!!!" will actually be rendered.
334+ *
335+ * If this flag is set to false, you need to explicitly evaluate the partial block.
336+ * The template myPartial.hbs will have to look like this:
337+ * <pre>
338+ * {{> @partial-block}}{{> myInline}}
339+ * </pre>
340+ *
341+ * Default is: true for compatibility reasons
342+ */
343+ private boolean preEvaluatePartialBlocks = true ;
344+
324345 /**
325346 * Creates a new {@link Handlebars} with no cache.
326347 *
@@ -775,38 +796,6 @@ public boolean stringParams() {
775796 }
776797
777798
778- /**
779- * If true, given partial blocks are not evaluated when defined but when used.
780- * If false, partial blocks are evaluated when defined and used.
781- * @return If true, given partial blocks are not evaluated when defined but when used.
782- * If false, partial blocks are evaluated when defined and used.
783- */
784- public boolean lazyPartialBlockEvaluation () {
785- return lazyPartialBlockEvaluation ;
786- }
787-
788-
789- /**
790- * If true, given partial blocks are not evaluated when defined but when used.
791- * If false, partial blocks are evaluated when defined and used.
792- * @param lazyPartialBlockEvaluation Flag to turn it off and on
793- */
794- public void setLazyPartialBlockEvaluation (final boolean lazyPartialBlockEvaluation ) {
795- this .lazyPartialBlockEvaluation = lazyPartialBlockEvaluation ;
796- }
797-
798- /**
799- * If true, given partial blocks are not evaluated when defined but when used.
800- * If false, partial blocks are evaluated when defined and used.
801- * @param lazyPartialBlockEvaluation Flag to turn it off and on
802- * @return The handlebars object.
803- */
804- public Handlebars lazyPartialBlockEvaluation (final boolean lazyPartialBlockEvaluation ) {
805- setLazyPartialBlockEvaluation (lazyPartialBlockEvaluation );
806- return this ;
807- }
808-
809-
810799 /**
811800 * If true, unnecessary spaces and new lines will be removed from output. Default is: false.
812801 *
@@ -1206,6 +1195,60 @@ public Handlebars parentScopeResolution(final boolean parentScopeResolution) {
12061195 return this ;
12071196 }
12081197
1198+ /**
1199+ * If true, partial blocks will implicitly be evaluated before the partials will actually
1200+ * be executed. If false, you need to explicitly evaluate and render partial blocks with
1201+ * <pre>
1202+ * {{> @partial-block}}
1203+ * </pre>
1204+ * Attention: If this is set to true, Handlebars works *much* slower!
1205+ *
1206+ * @return If true partial blocks will be evaluated before the partial will be rendered
1207+ * to allow inline block side effects.
1208+ * If false, you will have to evaluate and render partial blocks explitly (this
1209+ * option is *much* faster).
1210+ */
1211+ public boolean preEvaluatePartialBlocks () { return preEvaluatePartialBlocks ; }
1212+
1213+ /**
1214+ * If true, partial blocks will implicitly be evaluated before the partials will actually
1215+ * be executed. If false, you need to explicitly evaluate and render partial blocks with
1216+ * <pre>
1217+ * {{> @partial-block}}
1218+ * </pre>
1219+ * Attention: If this is set to true, Handlebars works *much* slower!
1220+ *
1221+ * @param preEvaluatePartialBlocks If true partial blocks will be evaluated before the
1222+ * partial will be rendered to allow inline block side
1223+ * effects.
1224+ * If false, you will have to evaluate and render partial
1225+ * blocks explitly (this option is *much* faster).
1226+ */
1227+ public void setPreEvaluatePartialBlocks (final boolean preEvaluatePartialBlocks ) {
1228+ this .preEvaluatePartialBlocks = preEvaluatePartialBlocks ;
1229+ }
1230+
1231+ /**
1232+ * If true, partial blocks will implicitly be evaluated before the partials will actually
1233+ * be executed. If false, you need to explicitly evaluate and render partial blocks with
1234+ *
1235+ * <pre>
1236+ * {{> @partial-block}}
1237+ * </pre>
1238+ * Attention: If this is set to true, Handlebars works *much* slower!
1239+ *
1240+ * @param preEvaluatePartialBlocks If true partial blocks will be evaluated before the
1241+ * partial will be rendered to allow inline block side
1242+ * effects.
1243+ * If false, you will have to evaluate and render partial
1244+ * blocks explitly (this option is *much* faster).
1245+ * @return The Handlebars object
1246+ */
1247+ public Handlebars preEvaluatePartialBlocks (final boolean preEvaluatePartialBlocks ) {
1248+ setPreEvaluatePartialBlocks (preEvaluatePartialBlocks );
1249+ return this ;
1250+ }
1251+
12091252 /**
12101253 * Return a parser factory.
12111254 *
0 commit comments