Comments (9)
@levani thanks for finding this core bug 👍 👏 I've gone ahead and patched it. I've also released a new version and deprecated all prior versions.
from cache-pug-templates.
@levani this is not a proper bug report - this code will not return undefined
. It returns a function since it eval's the template string (which is a function stored as a string).
from cache-pug-templates.
Well, I may be missing something but
cache[__path__] = eval('function test() {}')
would result in cache[__path__]
being undefined and creating test
function in global scope...
from cache-pug-templates.
It is pug.cache[filename] = eval(compiledStr);
, so pug.cache['some-file-name.pug'] = function test() {}
.
from cache-pug-templates.
If there's a bug here that I'm not seeing please file a pull request and I can review
from cache-pug-templates.
Or perhaps you could write a test case that shows it fails?
from cache-pug-templates.
I will try to send PR but I'm not quite sure that I'm right yet :))
In redis, functions are stored as strings like this:
function template(locals) {
var pug_html = ""
...
return pug_html;
}
than you eval
that string and assign it to an object property. Am I right?
Can you run this in browser console and see what's the value of o.file
?
let o = {};
o.file = eval('function template() { var html="test html"; return html; }')
from cache-pug-templates.
You have to wrap it with parenthesis to get desired output:
const o = {};
o.file = eval('(function template() { var html="test html"; return html; })');
from cache-pug-templates.
Please download v0.0.8+, thanks!
from cache-pug-templates.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cache-pug-templates.