Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch returns empty when the same template calls it more than once #11

Closed
lsycxyj opened this issue Mar 1, 2015 · 9 comments
Closed
Labels

Comments

@lsycxyj
Copy link

lsycxyj commented Mar 1, 2015

I call fetch successfully at the first time under nodejs, but after that it always returns empty string. I think there may be bugs due to caching after I read the source of jSmart.

jSmart.prototype.getTemplate = function(name){
    return xxx; //some parent content
}

var t1 = new jSmart('xxx'); //a template contains "extends"
var first = t1.fetch({xxx:'xxx'});//first is not empty
var t2 = new jSmart('xxx');//Same template as t1
var second = t2.fetch({xxx:'xxx'});//Same content as t1, but second is empty now
@Avcajaraville
Copy link

Im having the same issue here, all the problems comes with the nocache thing... This is totally stoping me from further development.

Is this repo. even maintained ?

Either we have to fix the cache template option or provide a way of disable it through the constructor.

@hereandnow
Copy link

I took a look into it, it should probably be fairly easy to fix:

just enable the "nocache" option param when calling getTemplate in the built-in extend parse function:

before:

getTemplate(trimQuotes(params.file?params.file:params[0]), tree);

after:

getTemplate(trimQuotes(params.file?params.file:params[0]), tree, true);

@alex-shamshurin
Copy link

Yes, I had the same issue. Thanks @hereandnow

@hereandnow
Copy link

@salex772: you could use @Avcajaraville's fork https://github.com/Avcajaraville/grunt-jsmart

it is at least a little maintained!

@Avcajaraville
Copy link

@salex772 The fork @hereandnow is referring is this one --> https://github.com/Avcajaraville/jsmart

The other one was a fork for grunt plugin.

So far, its doing the job for me, and since we are using it for some development process, whenever we find a missing feature, we will keep enhancing it.

@alex-shamshurin
Copy link

@Avcajaraville What about UMD and upload these all to npm?

@Avcajaraville
Copy link

@salex772 It have also UMD support. About uploading this to npm... yeah, will do that on the next days, since every day there is more people using it.

On the meantime, you can add a dependency to your package.json like this:

  ...
  "dependencies": {
    "jsmart": "Avcajaraville/jsmart#master"
  },
  ...

And then just require it as usually: var jsmart = require( 'jsmart' );

Hope this helps you.

@alex-shamshurin
Copy link

No, I prefer to wait for npm version and BTW, it should work with Webpack.

@umakantp
Copy link
Owner

This has been fixed in the release v2.15.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants