Closed tabarra closed 4 years ago
Thanks for the question @tabarra!
Actually, there should be a way to do this already.
In your data, you can set $cache
to false. So, for example, you can do:
console.log(renderFile('testview', {msg: 'Hello World', $cache: false}));
Let me know if this solves your problem, and if you have any more questions!
Hey @nebrelbug,
I'm having trouble with the cache option.
Consider test.js:
const Sqrl = require("squirrelly");
setInterval(() => {
let renderData = {
$cache: false,
msg: Math.random()
}
let result = Sqrl.renderFile('template.txt', renderData);
console.log(result);
}, 1000);
And template.txt:
aaa {{msg}} bbbb
I'm getting TypeError: Cannot read property 'slice' of undefined
when cache is set to false.
Screenshot of the terminal: https://i.imgur.com/PbjyMvm.png
Currently using squirrelly@7.1.3
btw.
Hi @tabarra, I figured out the problem! I'll try and push a fix by the middle of next week.
Thanks for the great questions and feedback!
Hi @tabarra! With Squirrelly 7.2.0, this issue should be fixed.
As warning, however, your custom function may be faster than renderFile
because renderFile
isn't async.
Hope this helps!
I am currently using the
renderFile()
function but would like to have squirrelly go get the file each time I call the function.For now I'm using the following "hack":
But it would be good if the
renderFile()
could have "no cache" as the third parameter.