Giter Club home page Giter Club logo

Comments (9)

niftylettuce avatar niftylettuce commented on May 22, 2024 1

@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.

niftylettuce avatar niftylettuce commented on May 22, 2024

@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.

levani avatar levani commented on May 22, 2024

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.

niftylettuce avatar niftylettuce commented on May 22, 2024

It is pug.cache[filename] = eval(compiledStr);, so pug.cache['some-file-name.pug'] = function test() {}.

from cache-pug-templates.

niftylettuce avatar niftylettuce commented on May 22, 2024

If there's a bug here that I'm not seeing please file a pull request and I can review

from cache-pug-templates.

niftylettuce avatar niftylettuce commented on May 22, 2024

Or perhaps you could write a test case that shows it fails?

from cache-pug-templates.

levani avatar levani commented on May 22, 2024

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.

niftylettuce avatar niftylettuce commented on May 22, 2024

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.

niftylettuce avatar niftylettuce commented on May 22, 2024

Please download v0.0.8+, thanks!

from cache-pug-templates.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.