Closed alensiljak closed 8 years ago
This is due to a bug in the AjaxMinifier. See https://github.com/madskristensen/BundlerMinifier/issues/63? Unfortunately this issue has been open for a long time and has still not been resolved. Can you add a request for a fix there - on their issue? (You can also link back this this issue.)
As for using the already minified version, https://www.jsviews.com/download/jsrender.min.js or https://cdnjs.cloudflare.com/ajax/libs/jsrender/0.9.72/jsrender.min.js - it should work correctly - with $.templates correctly defined.
If you are using JsRender alone, you don't need jquery.views.js - you should use jsrender.js (or jsrender.min.js) - which is for use either with or without jQuery.
In fact both jquery.views.js and jquery.observable.js are used for JsViews (templates plus data-binding and 'observable' data) when jsrender is already loaded. (Generally though, for JsViews, people use the single file version: jsviews.js, which combines jsrender.js, jquery.observable.js and jquery.views.js as a single file).
But is sounds like you are only intending to use JsRender.
See also http://www.jsviews.com/#download, http://www.jsviews.com/#jsr-quickstart and http://www.jsviews.com/#jsv-quickstart.
Oh, thanks for pointing out the underlying issue. I used the Bower package for v0.9.72 and I believe that by default it includes jsviews in the jsrender.js file. You are right that at the moment I'd use only jsrender to start replacing the previous jQuery Templates code. I'll cast my vote at the minifier project and will also look into specifying an alternate (i.e. YUI Compressor) as the minifying engine when building bundles. Thanks!
@MisterY: Well for JsRender you should have used $ bower install jsrender
- which would have given you bower_components/jsrender/jsrender.js etc. (not jquery.views.js or the others). See http://www.jsviews.com/#jsr-quickstart.
OTOH if you used $ bower install jsviews
, then you would have got both the separate files: jsrender, jquery.observable and jquery.views, and the combined file jsviews.js - all in bower_components/jsviews.
Let me know if the above is not the case!
Well, I've used bower install jsrender
and that contains only
and a few accompanying files (bower, index, license). Hence, I've tried including jsrender & the minified version but the results were as listed above.
@MisterY:
Well that's strange.
I just did a fresh bower install jsrender
, and then created a page with
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.3.js"></script>
<script src="jsrender.min.js"></script>
</head>
<body>
<script id="myTmpl" type="text/x-jsrender">
{{:name}}
</script>
<script>
var tmpl = $.templates("#myTmpl");
console.log(tmpl.render({name: "Jo"}));
</script>
</body>
</html>
It worked correctly and output "Jo" to the console.
Can you do the same? Do you see something different?
Thanks.
Boris
Closing for now, since I didn't hear back. Please let me know if this does not work for you now...
No problem. Sorry, I did not have the time to try this. I used a workaround for the original problem due to the timeframe available for a solution.
OK thanks - I'm going to assume there is no issue here, then - since that's what my testing says. Or else I had misunderstood what you were doing...
Using jsrender library (jsrender.js file) with ASP.NET MVC bundling and minification results in this error. The resulting minified code is
This is one of the first lines in factory (for jquery.views.js). Using the already minified version does not produce the exception on page load but .templates() is not available on $ (jQuery) in custom code. Using the non-jQuery call (window.jsrender) instead produces the same results. "TypeError: window.jsrender is undefined"