Swig-template default extension

Can I set what extension will be? For example:

 .html or .htm 

And can I set custom extension for some of layouts? Like:

 .xml

Swig doesn't care/know about extensions. You could try writing a custom loader to do this for you. Just copy the filesystem loader and have it check if a path given doesn't include an extension, and if it does, use your default.

var fs = require('fs'),
  path = require('path');

module.exports = function (basepath, encoding) {
  var ret = {};

  encoding = encoding || 'utf8';
  basepath = (basepath) ? path.normalize(basepath) : null;

  ret.resolve = function (to, from) {
    if (basepath) {
      from = basepath;
    } else {
      from = (from) ? path.dirname(from) : process.cwd();
    }
    return path.resolve(from, to);
  };

  ret.load = function (identifier, cb) {
    if (!fs || (cb && !fs.readFile) || !fs.readFileSync) {
      throw new Error('Unable to find file ' + identifier + ' because there is no filesystem to read from.');
    }

    // Start of added code...
    var extension = path.extname(identifier);

    if (!extension) {
      // Set this to whatever you want as a default
      // If the extension exists, like 'foo.xml', it won't add the '.html'
      identifier += '.html';
    }
    // End of added code

    identifier = ret.resolve(identifier);

    if (cb) {
      fs.readFile(identifier, encoding, cb);
      return;
    }
    return fs.readFileSync(identifier, encoding);
  };

  return ret;
};