Then create a further directory called html and a. Create a new directory named pug-examples and change into it. cache: boolean: If set to true, compiled functions are cached. Now that we’ve got Pug installed, let’s try it out. If you want to check what the cache state is at anytime: const pug = require('pug') Ĭonsole.log('pug cached files', Object.keys(pug. Add a list of global names to make accessible in templates. enable the Pug cache by setting the cache option to a writable directory, you can first cache all your template at. Since the version 3, it uses Phug, a very customizable Pug template engine made by Tale-pug and Pug-php developpers as the new PHP Pug engine reference. 1 cached file every 1000ms is the default), this value's default is 1000 Pug-php adds inline PHP scripting support to the Pug template compiler. interval (Number) - duration of time in (milliseconds) to limit concurrency for (e.g.concurrency (Number) - number of concurrent files that can be cached per interval in parallel (defaults to 1).
![pug template cache pug template cache](https://i.pinimg.com/originals/62/d8/69/62d869ead319629557e338c5f2de7cba.jpg)
If the view engine property is not set, you must specify the extension of the view file.
![pug template cache pug template cache](https://img1.etsystatic.com/209/2/16894770/il_340x270.1481666297_1z4a.jpg)
Then create a route to render the index.pug file.
![pug template cache pug template cache](https://i.pinimg.com/474x/b3/50/ff/b350ffc4b245847b678aa1eb139aa66d--pumpkin-stencil-bulldog.jpg)
callback (Function) - defaults to false (no operation), but if a function is provided then it will be invoked with two arguments, file (String) and template (Function).logger (Object) - a logger, defaults to console (we recommend using Cabin for your logger).views (String or Array) - a file directory path (or an Array of file directory paths) (if you pass an Express app instance as the app option, this will be automatically populated to your applications views configuration option via app.get('views')).app (Object) - an instance of Koa, Express, or Connect.Yarn: yarn add cache-pug-templates Usage Basic const path = require('path') Ĭonst CachePugTemplates = require('cache-pug-templates') Ĭonst views = path.join(_dirname, 'views') Ĭonst cache = new CachePugTemplates() Cache Pug templates for Lad/ Koa/ Express/ Connect.