djangosnippets.org: Latest snippets posted by kyprizelhttps://djangosnippets.org/users/kyprizel/2007-12-25T19:17:39.072519-06:00kyprizelpackjs templatetag
2007-12-25T19:17:39.072519-06:00kyprizelhttps://djangosnippets.org/snippets/524/<pre><code>Based on jspacker by Dean Edwards,
Python port by Florian Schulze: http://www.crowproductions.de/repos/main/public/packer/jspacker.py
Packs javascript
Example usage::
{% packjs %}
var a = 1;
var b = 2;
var c = 3;
alert(a+b);
{% endpackjs %}
This example would return this script::
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[c]=k[c]||c;k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp("\\b"+e(c)+"\\b","g"),k[c]);return p}('0 5 = 1;\n 0 4 …</code></pre>
Freely redistributableifsecure
2007-12-24T15:17:50.370872-06:00kyprizelhttps://djangosnippets.org/snippets/522/<p>In some cases we need to know if we were opened via https from template.</p>
<p>Usage:
{% ifsecure %}using https{% else %}not using https{% endifsecure %}</p>
<p>If you use fastcgi fastcgi_param HTTPS must exists.</p>
Freely redistributable