This is the current snippet that i am using
snippet req
const ${1:} = require('$1');
As you might have guessed it works well with packages that i installed from npm
but not so well for local file. Suppose i have a file at ../user.js
that i want to include in my nodejs project rather than showing up as
const ../user.js = require('../user.js');
I would like it to be as
const user = require('../user.js');
from what i assume i would somehow have to split the file path using /
get last element and again get first element after exploding with .
which would work well with both global install and local file inclusion. Problem is that i am new to snipmate
and have not figured out how can this be achieved. Any nudge in right direction is greatly appreciated. Thanks in advance for helping me out.
Update
Refering to snipmate documentation here, i found that i can use system
to utilize standard unix commands to perform operation on string. Now i am still stuck up on how to exactly pass $1
inside the system. Here is the updated code that i have
snippet req
const `system('echo $1')` = require('${1:}');