I have one code in node.js.
var testFunc = function( y, m, d ) {
//- do something~~
return chkDObj.getFullYear( ) == y && chkDObj.getMonth( ) == m && chkDObj.getDate( ) == d;
};
res.render( "index.jade", { testFunc: testFunc } );
In jade,
script
var tmp = #{testFunc}
I want it to show same thing, but render result is,
<script>
var tmp = function( u, m, d ) {
//- do something~~
return chkDObj.getFullYear( ) == y && chkDObj.getMonth( ) == m && chkDObj.getDate( ) == d;
};
</script>
How can I manage one source file?
You can create js file like a utils.js, which is accessible through http and such as Node.js module. It's simple and works.
Jade escapes all data by default. You can disable escaping by changing jour jade template:
script
var tmp = !{testFunc}