I want to add the charAt js function to stylus and i try the example posted in the stylus docs, is as follows:
var stylus = require('./node_modules/stylus')
, nodes = stylus.nodes
, utils = stylus.utils
, fs = require('fs');
function charAt(string, index) {
return string.charAt(index);
}
stylus(str)
.set('filename', 'js-functions')
.define('charAt', charAt)
.render(function(err, css){
if (err) throw err;
console.log(css);
});
I change the require path to my stylus dir and inside test.styl
i have the following:
use('js-functions.js')
when i run it a take the error:
ReferenceError: test.styl:1
> 1| use("js-functions.js")
2|
3|
4|
str is not defined
What is happening here?, what i a missing?, the docs not explain it very well for people who are new to node and stylus.