You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -253,6 +253,56 @@ public void DateTimeFormatter(IHandlebars handlebars)
253
253
#### Notes
254
254
- Formatters are resolved in reverse order according to registration. If multiple providers can provide formatter for a type the last registered would be used.
255
255
256
+
### Shared environment
257
+
258
+
By default Handlebars will create standalone copy of environment for each compiled template. This is done in order to eliminate a chance of altering behavior of one template from inside of other one.
259
+
260
+
Unfortunately, in case runtime has a lot of compiled templates (regardless of the template size) it may have significant memory footprint. This can be solved by using `SharedEnvironment`.
261
+
262
+
Templates compiled in `SharedEnvironment` will share the same configuration.
263
+
264
+
#### Limitations
265
+
266
+
Only runtime configuration properties can be changed after the shared environment has been created. Changes to `Configuration.CompileTimeConfiguration` and other compile-time properties will have no effect.
if (helpers?.TryGetValue(name, outvar@ref) ??false)
287
+
{
288
+
@ref.Value=newDelegateReturnHelperDescriptor(name, (c, a) =>42);
289
+
}
290
+
});
291
+
292
+
var_0_template="{{registerLateHelper}}";
293
+
var_0=handlebars.Compile(_0_template);
294
+
var_1_template="{{lateHelper}}";
295
+
var_1=handlebars.Compile(_1_template);
296
+
297
+
varresult=_1(null);
298
+
Assert.Equal("", result); // `lateHelper` is not registered yet
299
+
300
+
_0(null);
301
+
result=_1(null);
302
+
Assert.Equal("42", result);
303
+
}
304
+
```
305
+
256
306
### Compatibility feature toggles
257
307
258
308
Compatibility feature toggles defines a set of settings responsible for controlling compilation/rendering behavior. Each of those settings would enable certain feature that would break compatibility with canonical Handlebars.
0 commit comments