How can I force Rythm to parse and compile all templates in the home directory on init?

153 views Asked by At

While performing unit tests on my templates, I noticed that they only seem to be parsed and compiled the first time that they're used, and I can confirm that a template I created but never ended up using isn't getting parsed. For most use cases, this would be fine, but I'm a bit worried about a) the performance hit you take when a template needs to be compiled and b) what might happen in a multi-threaded environment if two (or more) threads need to use the same template, but it hasn't been compiled yet.

Even if my concerns are unjustified, it would still be nice to parse and compile all my templates on startup just to make sure they all compile, instead of having to wait until it's used. How can I do this?

1

There are 1 answers

0
Gelin Luo On BEST ANSWER

There are two configuration options to turn on precompile templates in Rythm:

  1. precompile_mode
  2. load_precompiled

The first one is to ask engine to precompile all templates into precompile dir, and the second one is ask the engine to load all precompiled templates from precompile dir.

Usually these configurations are used by certain plugins, e.g. play-rythm which makes rythm templates working with play 1's precompile support