Because Slab's parser looks for statements inside a single pair of curly braces, you might run into some issues with stuff you don't want to get parsed. The special keep statement can be used to escape parts of your template that you don't want to be included in parsing, such as inline scripts and styles:

The slab.compile function takes a template string and returns a new SlabTemplate object. The keys of this object correspond to the identifiers you used to declare your templates, with template function values. You can then pass a data object to these functions and you'll get a string return value.

Slab uses a regexp-based parser for compiling the templates into valid JavaScript functions. This compilation is a pretty expensive process, although the resulting final functions are quite fast.

While it's alright to use slab.compile during development, it's advised that you precompile your templates. Slab includes a slab.generate function that returns a template string that you can copy and paste to a separate file and include in your own application: