• Robert Knight's avatar
    Disable template caching in dev server · 0d33b0ce
    Robert Knight authored
    mustache-express caches templates by default unless Express's `view
    cache` option is explicitly set to `false`, as opposed to merely being
    unset. This is not mentioned in the documentation :(
    
    I debated whether to replace the mustache-express dependency with a
    custom integration. mustache-express does provide support for partials
    though which might be useful in future. For future reference, rendering
    templates without this dependency would look like:
    
    ```js
    app.engine('mustache', async (filePath, options, callback) => {
      try {
        const template = await fsPromises.readFile(filePath, {
          encoding: 'utf8',
        });
        const rendered = Mustache.render(template, options);
        callback(null, rendered);
      } catch (err) {
        callback(err);
      }
    });
    ```
    0d33b0ce
serve-dev.js 4.42 KB