Swig != Twig

The situation

You're migrating a PHP+Twig project to Node.js.

The surge of hope

You see that Swig is a thing. It looks like it's a clean replacement for Twig!

All my views will be instantly compatable!

you say, visions of saved work swimming through your head.

The letdown

I recently migrated a semi-large project to Node.js and Swig from SlimPHP and Twig. I thought the views would seamlessly copy from Swig to Twig, but the template conversion ended up being more headache-y than the PHP->Node sections.

The syntax between Twig and Swig is similar, but not identical.

{% embed %} just does not work, at all. The author seems to have no plans to fix this.

The import paths do not work the same.
Swig: in file /views/calendar/month.swig, include/base.swig resolves to /views/calendar/include/base.swig.
Twig: in file /views/calendar/month.twig, include/base.twig resolves to /views/include/base.twig

The error messages can look like this:

Error: SyntaxError: Unexpected token , in file /srv/http/gateway/views/calendar/month.swig.  
   at Object.exports.throwError (/srv/http/gateway/node_modules/swig/lib/utils.js:183:9)
   at precompile (/srv/http/gateway/node_modules/swig/lib/swig.js:505:13)
   at compile (/srv/http/gateway/node_modules/swig/lib/swig.js:606:16)
   at /srv/http/gateway/node_modules/swig/lib/swig.js:684:27
   at fs.js:336:14
   at FSReqWrap.oncomplete (fs.js:99:15) 

The takeaway

Though the potential compatability look promising, you're probably better off making the transition to Jade up front. A little extra work will save a lot of time and frustration.