oxen_media 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.bowerrc +3 -0
  3. data/.envrc +1 -0
  4. data/.gitignore +11 -0
  5. data/.rspec +3 -0
  6. data/.ruby-version +1 -0
  7. data/Gemfile +16 -0
  8. data/Gemfile.lock +331 -0
  9. data/Guardfile +135 -0
  10. data/MIT-LICENSE +20 -0
  11. data/README.rdoc +31 -0
  12. data/Rakefile +15 -0
  13. data/app/assets/images/oxen_media/.keep +0 -0
  14. data/app/assets/javascripts/jsrender.min.js +4 -0
  15. data/app/assets/javascripts/jsrender.min.js.map +463 -0
  16. data/app/assets/javascripts/oxen_media.js +3 -0
  17. data/app/assets/javascripts/oxen_media/.keep +0 -0
  18. data/app/assets/javascripts/oxen_media/carrier_wave_cropper.js.coffee +22 -0
  19. data/app/assets/javascripts/oxen_media/media.js.coffee +469 -0
  20. data/app/assets/javascripts/oxen_media/medium_pane.js.coffee +107 -0
  21. data/app/assets/javascripts/templates/selected_files.html +35 -0
  22. data/app/assets/stylesheets/media.css +10 -0
  23. data/app/assets/stylesheets/oxen_media/.keep +0 -0
  24. data/app/assets/stylesheets/scaffold.css +56 -0
  25. data/app/controllers/.keep +0 -0
  26. data/app/controllers/media_controller.rb +106 -0
  27. data/app/helpers/.keep +0 -0
  28. data/app/helpers/media_helper.rb +2 -0
  29. data/app/mailers/.keep +0 -0
  30. data/app/models/.keep +0 -0
  31. data/app/models/concerns/roleable.rb +61 -0
  32. data/app/models/medium.rb +25 -0
  33. data/app/policies/oxen_medium_policy.rb +12 -0
  34. data/app/uploaders/medium_uploader.rb +106 -0
  35. data/app/views/.keep +0 -0
  36. data/app/views/media/_fields.html.haml +42 -0
  37. data/app/views/media/_form.html.haml +48 -0
  38. data/app/views/media/_media.html.haml +18 -0
  39. data/app/views/media/_medium.html.haml +25 -0
  40. data/app/views/media/_medium_fields.html.haml +4 -0
  41. data/app/views/media/create.js.haml +2 -0
  42. data/app/views/media/crop.html.haml +3 -0
  43. data/app/views/media/edit.html.haml +2 -0
  44. data/app/views/media/index.html.haml +29 -0
  45. data/app/views/media/index.json.jbuilder +4 -0
  46. data/app/views/media/new.html.erb +5 -0
  47. data/app/views/media/show.html.haml +21 -0
  48. data/app/views/media/show.json.jbuilder +1 -0
  49. data/app/views/media/update_crop.js.haml +1 -0
  50. data/bin/rails +12 -0
  51. data/config/initializers/backtrace_silencers.rb +9 -0
  52. data/config/initializers/carrier_wave.rb +11 -0
  53. data/config/initializers/simple_form.rb +14 -0
  54. data/config/locales/media.en.yml +20 -0
  55. data/config/routes.rb +6 -0
  56. data/db/migrate/20150629071720_create_media.rb +13 -0
  57. data/lib/generators/media/USAGE +8 -0
  58. data/lib/generators/media/media_generator.rb +48 -0
  59. data/lib/generators/media/templates/medium.rb +13 -0
  60. data/lib/oxen_media.rb +7 -0
  61. data/lib/oxen_media/engine.rb +19 -0
  62. data/lib/oxen_media/version.rb +3 -0
  63. data/lib/tasks/oxen_media_tasks.rake +4 -0
  64. data/oxen_media.gemspec +59 -0
  65. data/test/controllers/media_controller_test.rb +49 -0
  66. data/test/fixtures/media.yml +17 -0
  67. data/test/integration/oxen_media_test.rb +7 -0
  68. data/test/lib/generators/media_generator_test.rb +14 -0
  69. data/test/models/medium_test.rb +7 -0
  70. data/test/test_helper.rb +13 -0
  71. metadata +387 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Walther H Diechmann
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,31 @@
1
+ = OxenMedia
2
+
3
+ == Dependencies
4
+
5
+ This gem depends (heavily) on the abstracted gem!
6
+
7
+ == Installation
8
+
9
+ You install the oxen_media gem simply by adding it to your Gemfile like this
10
+
11
+ `gem 'oxen_media'`
12
+
13
+ == Configuration
14
+
15
+ Once installed, you add the media table to your Rails DB migration management system like this
16
+
17
+ `rails g media medium`
18
+
19
+ Don't forget to _migrate_ ;)
20
+
21
+ Now you're ready to upload media - all you have to do is
22
+
23
+ - add `has_many :media, as: :imageable, dependent: :destroy` to the model which media should be attached
24
+ - add a medium_policy.rb to your policies
25
+ - add `= render 'media/media', f: f, medialist: 'media', url: new_stock_item_medium_url(resource)` to the model to which media should be attached
26
+
27
+ = TODO
28
+
29
+ 07-09-15 - use http://chocolat.insipi.de/ to 'lightbox' the images uploaded
30
+ 07-09-15 - use http://iamceege.github.io/tooltipster/ for tips
31
+ 03-07-15 - remember to install (on Linux) VIPS library like: $ apt-get install libvips-dev
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ # APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
8
+ # load 'rails/tasks/engine.rake'
9
+ # # Bundler::GemHelper.install_tasks
10
+ # Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
11
+ # require 'rspec/core'
12
+ # require 'rspec/core/rake_task'
13
+ # desc "Run all specs in spec directory (excluding plugin specs)"
14
+ # RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
15
+ # task :default => :spec
File without changes
@@ -0,0 +1,4 @@
1
+ /*! JsRender v1.0.0-beta: http://www.jsviews.com/#jsrender
2
+ informal pre V1.0 commit counter: 64*/
3
+ !function(e){if("function"==typeof define&&define.amd)define(e);else if("object"==typeof exports){var t=module.exports=e(!0,require("fs"));t.renderFile=t.__express=function(e,n,r){var i=t.templates("@"+e).render(n);return r&&r(null,i),i}}else e(!1)}(function(e,t){"use strict";function n(e,t){return function(){var n,r=this,i=r.base;return r.base=e,n=t.apply(r,arguments),r.base=i,n}}function r(e,t){return jt(t)&&(t=n(e?e._d?e:n(s,e):s,t),t._d=1),t}function i(e,t){for(var n in t.props)ct.test(n)&&(e[n]=r(e[n],t.props[n]))}function a(e){return e}function s(){return""}function o(e){try{throw"dbg breakpoint"}catch(t){}return this.base?this.baseApply(arguments):e}function l(e){Nt._dbgMode=e!==!1}function p(e){this.name=(G.link?"JsViews":"JsRender")+" Error",this.message=e||this.name}function d(e,t){var n;for(n in t)e[n]=t[n];return e}function u(e,t,n){return(0!==this||e)&&(W=e?e.charAt(0):W,X=e?e.charAt(1):X,Y=t?t.charAt(0):Y,et=t?t.charAt(1):et,tt=n||tt,e="\\"+W+"(\\"+tt+")?\\"+X,t="\\"+Y+"\\"+et,q="(?:(?:(\\w+(?=[\\/\\s\\"+Y+"]))|(?:(\\w+)?(:)|(>)|!--((?:[^-]|-(?!-))*)--|(\\*)))\\s*((?:[^\\"+Y+"]|\\"+Y+"(?!\\"+et+"))*?)",$t.rTag=q+")",q=new RegExp(e+q+"(\\/)?|(?:\\/(\\w+)))"+t,"g"),H=new RegExp("<.*>|([^\\\\]|^)[{}]|"+e+".*"+t)),[W,X,Y,et,tt]}function c(e,t){t||(t=e,e=void 0);var n,r,i,a,s=this,o=!t||"root"===t;if(e){if(a=s.type===t?s:void 0,!a)if(n=s.views,s._.useKey){for(r in n)if(a=n[r].get(e,t))break}else for(r=0,i=n.length;!a&&i>r;r++)a=n[r].get(e,t)}else if(o)for(;s.parent.parent;)a=s=s.parent;else for(;s&&!a;)a=s.type===t?s:void 0,s=s.parent;return a}function f(){var e=this.get("item");return e?e.index:void 0}function g(){return this.index}function v(e){var t,n=this,r=n.linkCtx,i=(n.ctx||{})[e];return void 0===i&&r&&r.ctx&&(i=r.ctx[e]),void 0===i&&(i=Mt[e]),i&&jt(i)&&!i._wrp&&(t=function(){return i.apply(this&&this!==z?this:n,arguments)},t._wrp=!0,d(t,i)),t||i}function m(e,t,n,r){var a,s,o="number"==typeof n&&t.tmpl.bnds[n-1],l=t.linkCtx;return void 0!==r?n=r={props:{},args:[r]}:o&&(n=o(t.data,t,kt)),s=n.args[0],(e||o)&&(a=l&&l.tag,a||(a=d(new $t._tg,{_:{inline:!l,bnd:o,unlinked:!0},tagName:":",cvt:e,flow:!0,tagCtx:n}),l&&(l.tag=a,a.linkCtx=l),n.ctx=J(n.ctx,(l?l.view:t).ctx)),a._er=r&&s,i(a,n),n.view=t,a.ctx=n.ctx||{},n.ctx=void 0,t._.tag=a,s=a.cvtArgs(a.convert||"true"!==e&&e)[0],s=o&&t._.onRender?t._.onRender(s,t,o):s,t._.tag=void 0),void 0!=s?s:""}function h(e){var t=this,n=t.tagCtx,r=n.view,i=n.args;return e=t.convert||e,e=e&&(""+e===e?r.getRsc("converters",e)||V("Unknown converter: '"+e+"'"):e),i=i.length||n.index?e?i.slice():i:[r.data],e&&(e.depends&&(t.depends=$t.getDeps(t.depends,t,e.depends,e)),i[0]=e.apply(t,i)),i}function w(e,t){for(var n,r,i=this;void 0===n&&i;)r=i.tmpl&&i.tmpl[e],n=r&&r[t],i=i.parent;return n||kt[e][t]}function x(e,t,n,r,a,s){t=t||D;var o,l,p,d,u,c,f,g,v,m,h,w,x,b,_,y,k,C,j="",A=t.linkCtx||0,T=t.ctx,M=n||t.tmpl,$="number"==typeof r&&t.tmpl.bnds[r-1];for("tag"===e._is?(o=e,e=o.tagName,r=o.tagCtxs,p=o.template):(l=t.getRsc("tags",e)||V("Unknown tag: {{"+e+"}} "),p=l.template),void 0!==s?(j+=s,r=s=[{props:{},args:[]}]):$&&(r=$(t.data,t,kt)),g=r.length,f=0;g>f;f++)m=r[f],(!A||!A.tag||f&&!A.tag._.inline||o._er)&&((w=m.tmpl)&&(w=m.content=M.tmpls[w-1]),m.index=f,m.tmpl=p||w,m.render=R,m.view=t,m.ctx=J(m.ctx,T)),(n=m.props.tmpl)&&(n=""+n===n?t.getRsc("templates",n)||Tt(n):n,m.tmpl=n),o||(o=new l._ctr,x=!!o.init,o.parent=c=T&&T.tag,o.tagCtxs=r,A&&(o._.inline=!1,A.tag=o,o.linkCtx=A),(o._.bnd=$||A.fn)?o._.arrVws={}:o.dataBoundOnly&&V("{^{"+e+"}} tag must be data-bound")),m.tag=o,o.dataMap&&o.tagCtxs&&(m.map=o.tagCtxs[f].map),o.flow||(h=m.ctx=m.ctx||{},d=o.parents=h.parentTags=T&&J(h.parentTags,T.parentTags)||{},c&&(d[c.tagName]=c),d[o.tagName]=h.tag=o);if(($||A)&&(t._.tag=o),!(o._er=s)){for(i(o,r[0]),o.rendering={},f=0;g>f;f++)m=o.tagCtx=o.tagCtxs[f],k=m.props,y=o.cvtArgs(),(b=k.dataMap||o.dataMap)&&(y.length||k.dataMap)&&(_=m.map,(!_||_.src!==y[0]||a)&&(_&&_.src&&_.unmap(),_=m.map=b.map(y[0],k)),y=[_.tgt]),o.ctx=m.ctx,f||(x&&(C=o.template,o.init(m,A,o.ctx),x=void 0,o.template!==C&&(o._.tmpl=o.template)),A&&(A.attr=o.attr=A.attr||o.attr),u=o.attr,o._.noVws=u&&u!==ht),v=void 0,o.render&&(v=o.render.apply(o,y)),y.length||(y=[t]),void 0===v&&(v=m.render(y.length?y[0]:t,!0)||(a?void 0:"")),j=j?j+(v||""):v;o.rendering=void 0}return o.tagCtx=o.tagCtxs[0],o.ctx=o.tagCtx.ctx,o._.noVws&&o._.inline&&(j="text"===u?Rt.html(j):""),$&&t._.onRender?t._.onRender(j,t,$):j}function b(e,t,n,r,i,a,s,o){var l,p,d,u,c=this,g="array"===t;c.content=s,c.views=g?[]:{},c.parent=n,c.type=t||"top",c.data=r,c.tmpl=i,u=c._={key:0,useKey:g?0:1,id:""+vt++,onRender:o,bnds:{}},c.linked=!!o,n?(l=n.views,p=n._,p.useKey?(l[u.key="_"+p.useKey++]=c,c.index=bt,c.getIndex=f,d=p.tag,u.bnd=g&&(!d||!!d._.bnd&&d)):l.length===(u.key=c.index=a)?l.push(c):l.splice(a,0,c),c.ctx=e||n.ctx):c.ctx=e}function _(e){var t,n,r,i,a,s,o;for(t in yt)if(a=yt[t],(s=a.compile)&&(n=e[t+"s"]))for(r in n)i=n[r]=s(r,n[r],e,0),i._is=t,i&&(o=$t.onStore[t])&&o(r,i,s)}function y(e,t,n){function i(){var t=this;t._={inline:!0,unlinked:!0},t.tagName=e}var a,s,o,l=new $t._tg;if(jt(t)?t={depends:t.depends,render:t}:""+t===t&&(t={template:t}),s=t.baseTag){t.flow=!!t.flow,t.baseTag=s=""+s===s?n&&n.tags[s]||Vt[s]:s,l=d(l,s);for(o in t)l[o]=r(s[o],t[o])}else l=d(l,t);return void 0!==(a=l.template)&&(l.template=""+a===a?Tt[a]||Tt(a):a),l.init!==!1&&((i.prototype=l).constructor=l._ctr=i),n&&(l._parentTmpl=n),l}function k(e){return this.base.apply(this,e)}function C(e,n,r,i){function a(n){var a;if(""+n===n||n.nodeType>0&&(s=n)){if(!s)if("@"===n.charAt(0))t?n=Tt[e=e||(n=t.realpathSync(n.slice(1)))]=Tt[e]||C(e,t.readFileSync(n,"utf8"),r,i):s=P.getElementById(n);else if(G.fn&&!H.test(n))try{s=G(P).find(n)[0]}catch(o){}s&&(i?n=s.innerHTML:((a=s.getAttribute(xt))&&(n=Tt[a])&&e!==a&&delete Tt[a],e=e||a||"_"+gt++,a||(n=C(e,s.innerHTML,r,i)),s.setAttribute(xt,e),Tt[n.tmplName=e]=n),s=void 0)}else n.fn||(n=void 0);return n}var s,o,l=n=n||"";return 0===i&&(i=void 0,l=a(l)),i=i||(n.markup?n:{}),i.tmplName=e,r&&(i._parentTmpl=r),!l&&n.markup&&(l=a(n.markup))&&l.fn&&(l=l.markup),void 0!==l?(l.fn||n.fn?l.fn&&(o=l):(n=A(l,i),N(l.replace(st,"\\$&"),n)),o||(_(i),o=d(function(){return n.render.apply(n,arguments)},n)),e&&!r&&(_t[e]=o),o):void 0}function j(e){function t(t,n){this.tgt=e.getTgt(t,n)}return jt(e)&&(e={getTgt:e}),e.baseMap&&(e=d(d({},e.baseMap),e)),e.map=function(e,n){return new t(e,n)},e}function A(e,t){var n,r=Nt.wrapMap||{},i=d({tmpls:[],links:{},bnds:[],_is:"template",render:R},t);return i.markup=e,t.htmlTag||(n=pt.exec(e),i.htmlTag=n?n[1].toLowerCase():""),n=r[i.htmlTag],n&&n!==r.div&&(i.markup=G.trim(i.markup)),i}function T(e,t){function n(i,a,s){var o,l,p,d;if(i&&typeof i===wt&&!i.nodeType&&!i.markup&&!i.getTgt){for(p in i)n(p,i[p],a);return kt}return void 0===a&&(a=i,i=void 0),i&&""+i!==i&&(s=a,a=i,i=void 0),d=s?s[r]=s[r]||{}:n,l=t.compile,null===a?i&&delete d[i]:(a=l?l(i,a,s,0):a,i&&(d[i]=a)),l&&a&&(a._is=e),a&&(o=$t.onStore[e])&&o(i,a,l),a}var r=e+"s";kt[r]=n}function R(e,t,n,r,i,a){var s,o,l,p,d,u,c,f,g=r,v="";if(t===!0?(n=t,t=void 0):typeof t!==wt&&(t=void 0),(l=this.tag)?(d=this,p=l._.tmpl||d.tmpl,g=g||d.view,arguments.length||(e=g)):p=this,p){if(!g&&e&&"view"===e._is&&(g=e),g&&e===g&&(e=g.data),p.fn||(p=l._.tmpl=Tt[p]||Tt(p)),Q=Q||(u=!g),g||((t=t||{}).root=e),!Q||p.useViews)v=M(p,e,t,n,g,i,a,l);else{if(g?(c=g.data,f=g.index,g.index=bt):(g=D,g.data=e,g.ctx=t),At(e)&&!n)for(s=0,o=e.length;o>s;s++)g.index=s,g.data=e[s],v+=p.fn(e[s],g,kt);else v+=p.fn(e,g,kt);g.data=c,g.index=f}u&&(Q=void 0)}return v}function M(e,t,n,r,i,a,s,o){function l(e){_=d({},n),_[x]=e}var p,u,c,f,g,v,m,h,w,x,_,y,k="";if(o&&(w=o.tagName,y=o.tagCtx,n=n?J(n,o.ctx):o.ctx,m=y.content,y.props.link===!1&&(n=n||{},n.link=!1),(x=y.props.itemVar)&&("~"!==x.charAt(0)&&$("Use itemVar='~myItem'"),x=x.slice(1))),i&&(m=m||i.content,s=s||i._.onRender,n=n||i.ctx),a===!0&&(v=!0,a=0),s&&(n&&n.link===!1||o&&o._.noVws)&&(s=void 0),h=s,s===!0&&(h=void 0,s=i._.onRender),n=e.helpers?J(e.helpers,n):n,_=n,At(t)&&!r)for(c=v?i:void 0!==a&&i||new b(n,"array",i,t,e,a,m,s),x&&(c.it=x),x=c.it,p=0,u=t.length;u>p;p++)x&&l(t[p]),f=new b(_,"item",c,t[p],e,(a||0)+p,m,s),g=e.fn(t[p],f,kt),k+=c._.onRender?c._.onRender(g,f):g;else x&&l(t),c=v?i:new b(_,w||"data",i,t,e,a,m,s),o&&!o.flow&&(c.tag=o),k+=e.fn(t,c,kt);return h?h(k,c):k}function V(e,t,n){var r=Nt.onError(e,t,n);if(""+e===e)throw new $t.Err(r);return!t.linkCtx&&t.linked?Rt.html(r):r}function $(e){V("Syntax error\n"+e)}function N(e,t,n,r,i){function a(t){t-=f,t&&v.push(e.substr(f,t).replace(it,"\\n"))}function s(t,n){t&&(t+="}}",$((n?"{{"+n+"}} block has {{/"+t+" without {{"+t:"Unmatched or missing {{/"+t)+", in template:\n"+e))}function o(o,l,c,h,w,x,b,_,y,k,C,j){x&&(w=":",h=ht),k=k||n&&!i;var A=(l||n)&&[[]],T="",R="",M="",V="",N="",E="",S="",U="",J=!k&&!w&&!b;c=c||(y=y||"#data",w),a(j),f=j+o.length,_?u&&v.push(["*","\n"+y.replace(/^:/,"ret+= ").replace(at,"$1")+";\n"]):c?("else"===c&&(lt.test(y)&&$('for "{{else if expr}}" use "{{else expr}}"'),A=m[7]&&[[]],m[8]=e.substring(m[8],j),m=g.pop(),v=m[2],J=!0),y&&I(y.replace(it," "),A,t).replace(ot,function(e,t,n,r,i,a,s,o){return r="'"+i+"':",s?(R+=a+",",V+="'"+o+"',"):n?(M+=r+a+",",E+=r+"'"+o+"',"):t?S+=a:("trigger"===i&&(U+=a),T+=r+a+",",N+=r+"'"+o+"',",d=d||ct.test(i)),""}).slice(0,-1),A&&A[0]&&A.pop(),p=[c,h||!!r||d||"",J&&[],F(V,N,E),F(R,T,M),S,U,A||0],v.push(p),J&&(g.push(m),m=p,m[8]=f)):C&&(s(C!==m[0]&&"else"!==m[0]&&C,m[0]),m[8]=e.substring(m[8],j),m=g.pop()),s(!m&&C),v=m[2]}var l,p,d,u=Nt.allowCode||t&&t.allowCode,c=[],f=0,g=[],v=c,m=[,,c];return u&&(t.allowCode=u),n&&(e=W+e+et),s(g[0]&&g[0][2].pop()[0]),e.replace(q,o),a(e.length),(f=c[c.length-1])&&s(""+f!==f&&+f[8]===f[8]&&f[0]),n?(l=U(c,e,n),E(l,[c[0][7]])):l=U(c,t),l}function E(e,t){var n,r,i=0,a=t.length;for(e.deps=[];a>i;i++){r=t[i];for(n in r)"_jsvto"!==n&&r[n].length&&(e.deps=e.deps.concat(r[n]))}e.paths=r}function F(e,t,n){return[e.slice(0,-1),t.slice(0,-1),n.slice(0,-1)]}function S(e,t){return"\n "+(t?t+":{":"")+"args:["+e[0]+"]"+(e[1]||!t?",\n props:{"+e[1]+"}":"")+(e[2]?",\n ctx:{"+e[2]+"}":"")}function I(e,t,n){function r(r,h,w,x,b,_,y,k,C,j,A,T,R,M,V,E,F,S,I,U){function J(e,n,r,s,o,l,u,c){var f="."===r;if(r&&(b=b.slice(n.length),f||(e=(s?'view.hlp("'+s+'")':o?"view":"data")+(c?(l?"."+l:s?"":o?"":"."+r)+(u||""):(c=s?"":o?l||"":r,"")),e+=c?"."+c:"",e=n+("view.data"===e.slice(0,9)?e.slice(5):e)),p)){if(B="linkTo"===i?a=t._jsvto=t._jsvto||[]:d.bd,L=f&&B[B.length-1]){if(L._jsv){for(;L.sb;)L=L.sb;L.bnd&&(b="^"+b.slice(1)),L.sb=b,L.bnd=L.bnd||"^"===b.charAt(0)}}else B.push(b);m[g]=I+(f?1:0)}return e}x=p&&x,x&&!k&&(b=x+b),_=_||"",w=w||h||T,b=b||C,j=j||F||"";var K,O,B,L,q;if(!y||l||o){if(p&&E&&!l&&!o&&(!i||s||a)&&(K=m[g-1],U.length-1>I-(K||0))){if(K=U.slice(K,I+r.length),O!==!0)if(B=a||u[g-1].bd,L=B[B.length-1],L&&L.prm){for(;L.sb&&L.sb.prm;)L=L.sb;q=L.sb={path:L.sb,bnd:L.bnd}}else B.push(q={path:B.pop()});E=X+":"+K+" onerror=''"+Y,O=f[E],O||(f[E]=!0,f[E]=O=N(E,n,!0)),O!==!0&&q&&(q._jsv=O,q.prm=d.bd,q.bnd=q.bnd||q.path&&q.path.indexOf("^")>=0)}return l?(l=!R,l?r:T+'"'):o?(o=!M,o?r:T+'"'):(w?(m[g]=I++,d=u[++g]={bd:[]},w):"")+(S?g?"":(c=U.slice(c,I),(i?(i=s=a=!1,"\b"):"\b,")+c+(c=I+r.length,p&&t.push(d.bd=[]),"\b")):k?(g&&$(e),p&&t.pop(),i=b,s=x,c=I+r.length,x&&(p=d.bd=t[i]=[]),b+":"):b?b.split("^").join(".").replace(nt,J)+(j?(d=u[++g]={bd:[]},v[g]=!0,j):_):_?_:V?(v[g]=!1,d=u[--g],V+(j?(d=u[++g],v[g]=!0,j):"")):A?(v[g]||$(e),","):h?"":(l=R,o=M,'"'))}$(e)}var i,a,s,o,l,p=t&&t[0],d={bd:p},u={0:d},c=0,f=n?n.links:p&&(p.links=p.links||{}),g=0,v={},m={};return(e+(n?" ":"")).replace(rt,r)}function U(e,t,n){var r,i,a,s,o,l,p,d,u,c,f,g,v,m,h,w,x,b,_,y,k,C,j,T,R,M,V,N,F,I,J=0,K=t.useViews||t.tags||t.templates||t.helpers||t.converters,O="",B={},L=e.length;for(""+t===t?(b=n?'data-link="'+t.replace(it," ").slice(1,-1)+'"':t,t=0):(b=t.tmplName||"unnamed",t.allowCode&&(B.allowCode=!0),t.debug&&(B.debug=!0),f=t.bnds,x=t.tmpls),r=0;L>r;r++)if(i=e[r],""+i===i)O+='\n+"'+i+'"';else if(a=i[0],"*"===a)O+=";\n"+i[1]+"\nret=ret";else{if(s=i[1],k=!n&&i[2],o=S(i[3],"params")+"},"+S(v=i[4]),N=i[5],I=i[6],C=i[8]&&i[8].replace(at,"$1"),(R="else"===a)?g&&g.push(i[7]):(J=0,f&&(g=i[7])&&(g=[g],J=f.push(1))),K=K||v[1]||v[2]||g||/view.(?!index)/.test(v[0]),(M=":"===a)?s&&(a=s===ht?">":s+a):(k&&(_=A(C,B),_.tmplName=b+"/"+a,_.useViews=_.useViews||K,U(k,_),K=_.useViews,x.push(_)),R||(y=a,K=K||a&&(!Vt[a]||!Vt[a].flow),T=O,O=""),j=e[r+1],j=j&&"else"===j[0]),F=N?";\ntry{\nret+=":"\n+",m="",h="",M&&(g||I||s&&s!==ht)){if(V="return {"+o+"};",w='c("'+s+'",view,',V=new Function("data,view,j,u"," // "+b+" "+J+" "+a+"\n"+V),V._er=N,m=w+J+",",h=")",V._tag=a,n)return V;E(V,g),c=!0}if(O+=M?(n?(N?"\ntry{\n":"")+"return ":F)+(c?(c=void 0,K=u=!0,w+(g?(f[J-1]=V,J):"{"+o+"}")+")"):">"===a?(p=!0,"h("+v[0]+")"):(d=!0,"((v="+(v[0]||"data")+')!=null?v:"")')):(l=!0,"\n{view:view,tmpl:"+(k?x.length:"0")+","+o+"},"),y&&!j){if(O="["+O.slice(0,-1)+"]",w='t("'+y+'",view,this,',n||g){if(O=new Function("data,view,j,u"," // "+b+" "+J+" "+y+"\nreturn "+O+";"),O._er=N,O._tag=y,g&&E(f[J-1]=O,g),n)return O;m=w+J+",undefined,",h=")"}O=T+F+w+(J||O)+")",g=0,y=0}N&&(K=!0,O+=";\n}catch(e){ret"+(n?"urn ":"+=")+m+"j._err(e,view,"+N+")"+h+";}\n"+(n?"":"ret=ret"))}O="// "+b+"\nvar v"+(l?",t=j._tag":"")+(u?",c=j._cnvt":"")+(p?",h=j.converters.html":"")+(n?";\n":',ret=""\n')+(B.debug?"debugger;":"")+O+(n?"\n":";\nreturn ret;"),Nt._dbgMode&&(O="try {\n"+O+"\n}catch(e){\nreturn j._err(e, view);\n}");try{O=new Function("data,view,j,u",O)}catch(q){$("Compiled template code:\n\n"+O+'\n: "'+q.message+'"')}return t&&(t.fn=O,t.useViews=!!K),O}function J(e,t){return e&&e!==t?t?d(d({},t),e):e:t&&d({},t)}function K(e){return mt[e]||(mt[e]="&#"+e.charCodeAt(0)+";")}function O(e){var t,n,r=[];if(typeof e===wt)for(t in e)n=e[t],n&&n.toJSON&&!n.toJSON()||jt(n)||r.push({key:t,prop:n});return r}function B(e){return void 0!=e?ut.test(e)&&(""+e).replace(ft,K)||e:""}e=e===!0;var L,q,H,D,Q,Z="v1.0.0-beta",z=(0,eval)("this"),G=z.jQuery,P=z.document,W="{",X="{",Y="}",et="}",tt="^",nt=/^(!*?)(?:null|true|false|\d[\d.]*|([\w$]+|\.|~([\w$]+)|#(view|([\w$]+))?)([\w$.^]*?)(?:[.[^]([\w$]+)\]?)?)$/g,rt=/(\()(?=\s*\()|(?:([([])\s*)?(?:(\^?)(!*?[#~]?[\w$.^]+)?\s*((\+\+|--)|\+|-|&&|\|\||===|!==|==|!=|<=|>=|[<>%*:?\/]|(=))\s*|(!*?[#~]?[\w$.^]+)([([])?)|(,\s*)|(\(?)\\?(?:(')|("))|(?:\s*(([)\]])(?=\s*[.^]|\s*$|[^\(\[])|[)\]])([([]?))|(\s+)/g,it=/[ \t]*(\r\n|\n|\r)/g,at=/\\(['"])/g,st=/['"\\]/g,ot=/(?:\x08|^)(onerror:)?(?:(~?)(([\w$_\.]+):)?([^\x08]+))\x08(,)?([^\x08]+)/gi,lt=/^if\s/,pt=/<(\w+)[>\s]/,dt=/[\x00`><"'&]/g,ut=/[\x00`><\"'&]/,ct=/^on[A-Z]|^convert(Back)?$/,ft=dt,gt=0,vt=0,mt={"&":"&amp;","<":"&lt;",">":"&gt;","\x00":"&#0;","'":"&#39;",'"':"&#34;","`":"&#96;"},ht="html",wt="object",xt="data-jsv-tmpl",bt="For #index in nested block use #getIndex().",_t={},yt={template:{compile:C},tag:{compile:y},helper:{},converter:{}},kt={jsviews:Z,settings:function(e){d(Nt,e),l(Nt._dbgMode),Nt.jsv&&Nt.jsv()},sub:{View:b,Err:p,tmplFn:N,parse:I,extend:d,syntaxErr:$,onStore:{},_ths:i,_tg:function(){}},map:j,_cnvt:m,_tag:x,_err:V},Ct=z.jsviews;(p.prototype=new Error).constructor=p,f.depends=function(){return[this.get("item"),"index"]},g.depends="index",b.prototype={get:c,getIndex:g,getRsc:w,hlp:v,_is:"view"};for(L in yt)T(L,yt[L]);var jt,At,Tt=kt.templates,Rt=kt.converters,Mt=kt.helpers,Vt=kt.tags,$t=kt.sub,Nt=kt.settings;return $t._tg.prototype={baseApply:k,cvtArgs:h},D=$t.topView=new b,G?(G.fn.render=function(e,t,n){var r=this.jquery&&(this[0]||V('Unknown template: "'+this.selector+'"')),i=r.getAttribute(xt);return R.call(i?Tt[i]:Tt(r),e,t,n)},G.observable&&(d($t,G.views.sub),kt.map=G.views.map)):(G={},e||(z.jsviews=G),G.isFunction=function(e){return"function"==typeof e},G.isArray=Array.isArray||function(e){return"[object Array]"===G.toString.call(e)},G.noConflict=function(){return z.jsviews===G&&(z.jsviews=Ct),G}),jt=G.isFunction,At=G.isArray,G.render=_t,G.views=kt,G.templates=Tt=kt.templates,kt.compile=function(e,t){return t=t||{},t.markup=e,Tt(t)},Nt({debugMode:l,delimiters:u,onError:function(e,t,n){return t&&(e=void 0===n?"{Error: "+(e.message||e)+"}":jt(n)?n(e,t):n),void 0==e?"":e},_dbgMode:!1}),Vt({"if":{render:function(e){var t=this,n=t.tagCtx,r=t.rendering.done||!e&&(arguments.length||!n.index)?"":(t.rendering.done=!0,t.selected=n.index,n.render(n.view,!0));return r},flow:!0},"for":{render:function(e){var t,n=!arguments.length,r=this,i=r.tagCtx,a="",s=0;return r.rendering.done||(t=n?i.view.data:e,void 0!==t&&(a+=i.render(t,n),s+=At(t)?t.length:1),(r.rendering.done=s)&&(r.selected=i.index)),a},flow:!0},props:{baseTag:"for",dataMap:j(O),flow:!0},include:{flow:!0},"*":{render:a,flow:!0},":*":{render:a,flow:!0},dbg:Mt.dbg=Rt.dbg=o}),Rt({html:B,attr:B,url:function(e){return void 0!=e?encodeURI(""+e):null===e?e:""}}),u(),kt});
4
+ //# sourceMappingURL=jsrender.min.js.map
@@ -0,0 +1,463 @@
1
+ {
2
+ version: 3,
3
+ sources: [
4
+ "jsrender.js"
5
+ ],
6
+ names: [
7
+ "factory",
8
+ "global",
9
+ "eval",
10
+ "$",
11
+ "jQuery",
12
+ "define",
13
+ "amd",
14
+ "exports",
15
+ "module",
16
+ "fn",
17
+ "getDerivedMethod",
18
+ "baseMethod",
19
+ "method",
20
+ "ret",
21
+ "tag",
22
+ "this",
23
+ "prevBase",
24
+ "base",
25
+ "apply",
26
+ "arguments",
27
+ "getMethod",
28
+ "$isFunction",
29
+ "_d",
30
+ "noop",
31
+ "tagHandlersFromProps",
32
+ "tagCtx",
33
+ "prop",
34
+ "props",
35
+ "rHasHandlers",
36
+ "test",
37
+ "retVal",
38
+ "val",
39
+ "dbgBreak",
40
+ "e",
41
+ "baseApply",
42
+ "dbgMode",
43
+ "debugMode",
44
+ "$viewsSettings",
45
+ "_dbgMode",
46
+ "JsViewsError",
47
+ "message",
48
+ "name",
49
+ "link",
50
+ "$extend",
51
+ "target",
52
+ "source",
53
+ "$viewsDelimiters",
54
+ "openChars",
55
+ "closeChars",
56
+ "delimOpenChar0",
57
+ "charAt",
58
+ "delimOpenChar1",
59
+ "delimCloseChar0",
60
+ "delimCloseChar1",
61
+ "linkChar",
62
+ "rTag",
63
+ "$sub",
64
+ "RegExp",
65
+ "rTmplString",
66
+ "getView",
67
+ "inner",
68
+ "type",
69
+ "undefined",
70
+ "views",
71
+ "i",
72
+ "l",
73
+ "found",
74
+ "view",
75
+ "root",
76
+ "_",
77
+ "useKey",
78
+ "get",
79
+ "length",
80
+ "parent",
81
+ "getNestedIndex",
82
+ "index",
83
+ "getIndex",
84
+ "getHelper",
85
+ "helper",
86
+ "wrapped",
87
+ "ctx",
88
+ "linkCtx",
89
+ "res",
90
+ "$helpers",
91
+ "_wrp",
92
+ "convertVal",
93
+ "converter",
94
+ "onError",
95
+ "value",
96
+ "boundTag",
97
+ "tmpl",
98
+ "bnds",
99
+ "args",
100
+ "data",
101
+ "$views",
102
+ "_tg",
103
+ "inline",
104
+ "bnd",
105
+ "unlinked",
106
+ "tagName",
107
+ "cvt",
108
+ "flow",
109
+ "extendCtx",
110
+ "_er",
111
+ "cvtArgs",
112
+ "convert",
113
+ "onRender",
114
+ "convertArgs",
115
+ "getRsc",
116
+ "error",
117
+ "slice",
118
+ "depends",
119
+ "getDeps",
120
+ "getResource",
121
+ "resourceType",
122
+ "itemName",
123
+ "store",
124
+ "renderTag",
125
+ "parentView",
126
+ "tagCtxs",
127
+ "isUpdate",
128
+ "topView",
129
+ "tagDef",
130
+ "template",
131
+ "tags",
132
+ "attr",
133
+ "parentTag",
134
+ "itemRet",
135
+ "tagCtxCtx",
136
+ "content",
137
+ "callInit",
138
+ "mapDef",
139
+ "thisMap",
140
+ "initialTmpl",
141
+ "tagDataMap",
142
+ "parentTmpl",
143
+ "_is",
144
+ "tmpls",
145
+ "render",
146
+ "renderContent",
147
+ "$templates",
148
+ "_ctr",
149
+ "init",
150
+ "dataMap",
151
+ "arrVws",
152
+ "dataBoundOnly",
153
+ "map",
154
+ "parents",
155
+ "parentTags",
156
+ "rendering",
157
+ "src",
158
+ "unmap",
159
+ "tgt",
160
+ "noVws",
161
+ "HTML",
162
+ "$converters",
163
+ "html",
164
+ "View",
165
+ "context",
166
+ "key",
167
+ "contentTmpl",
168
+ "parentView_",
169
+ "self_",
170
+ "self",
171
+ "isArray",
172
+ "id",
173
+ "viewId",
174
+ "linked",
175
+ "indexStr",
176
+ "push",
177
+ "splice",
178
+ "compileChildResources",
179
+ "storeName",
180
+ "resources",
181
+ "resourceName",
182
+ "resource",
183
+ "settings",
184
+ "compile",
185
+ "onStore",
186
+ "jsvStores",
187
+ "compileTag",
188
+ "Tag",
189
+ "baseTag",
190
+ "compiledDef",
191
+ "$tags",
192
+ "prototype",
193
+ "constructor",
194
+ "_parentTmpl",
195
+ "compileTmpl",
196
+ "options",
197
+ "lookupTemplate",
198
+ "currentName",
199
+ "nodeType",
200
+ "elem",
201
+ "document",
202
+ "getElementById",
203
+ "find",
204
+ "innerHTML",
205
+ "getAttribute",
206
+ "tmplAttr",
207
+ "jsvTmpl",
208
+ "tmplName",
209
+ "setAttribute",
210
+ "compiledTmpl",
211
+ "tmplOrMarkup",
212
+ "markup",
213
+ "tmplObject",
214
+ "tmplFn",
215
+ "replace",
216
+ "rEscapeQuotes",
217
+ "$render",
218
+ "Map",
219
+ "getTgt",
220
+ "baseMap",
221
+ "htmlTag",
222
+ "wrapMap",
223
+ "links",
224
+ "rFirstElem",
225
+ "exec",
226
+ "toLowerCase",
227
+ "div",
228
+ "trim",
229
+ "registerStore",
230
+ "storeSettings",
231
+ "theStore",
232
+ "item",
233
+ "thisStore",
234
+ "OBJECT",
235
+ "storeNames",
236
+ "noIteration",
237
+ "isTopRenderCall",
238
+ "prevData",
239
+ "prevIndex",
240
+ "result",
241
+ "isRenderCall",
242
+ "useViews",
243
+ "renderWithViews",
244
+ "$isArray",
245
+ "setItemVar",
246
+ "newCtx",
247
+ "itemVar",
248
+ "newView",
249
+ "childView",
250
+ "itemResult",
251
+ "swapContent",
252
+ "outerOnRender",
253
+ "syntaxError",
254
+ "helpers",
255
+ "it",
256
+ "fallback",
257
+ "Err",
258
+ "isLinkExpr",
259
+ "convertBack",
260
+ "hasElse",
261
+ "pushprecedingContent",
262
+ "shift",
263
+ "loc",
264
+ "substr",
265
+ "rNewLine",
266
+ "blockTagCheck",
267
+ "block",
268
+ "parseTag",
269
+ "all",
270
+ "bind",
271
+ "colon",
272
+ "comment",
273
+ "codeTag",
274
+ "params",
275
+ "slash",
276
+ "closeBlock",
277
+ "pathBindings",
278
+ "ctxProps",
279
+ "paramsArgs",
280
+ "paramsProps",
281
+ "paramsCtxProps",
282
+ "useTrigger",
283
+ "allowCode",
284
+ "rUnescapeQuotes",
285
+ "rTestElseIf",
286
+ "current",
287
+ "substring",
288
+ "stack",
289
+ "pop",
290
+ "parseParams",
291
+ "rBuildHash",
292
+ "onerror",
293
+ "isCtx",
294
+ "keyToken",
295
+ "keyValue",
296
+ "arg",
297
+ "param",
298
+ "hasHandlers",
299
+ "newNode",
300
+ "parsedParam",
301
+ "astTop",
302
+ "buildCode",
303
+ "setPaths",
304
+ "pathsArr",
305
+ "paths",
306
+ "deps",
307
+ "concat",
308
+ "paramStructure",
309
+ "parts",
310
+ "parseTokens",
311
+ "lftPrn0",
312
+ "lftPrn",
313
+ "bound",
314
+ "path",
315
+ "operator",
316
+ "err",
317
+ "eq",
318
+ "path2",
319
+ "prn",
320
+ "comma",
321
+ "lftPrn2",
322
+ "apos",
323
+ "quot",
324
+ "rtPrn",
325
+ "rtPrnDot",
326
+ "prn2",
327
+ "space",
328
+ "full",
329
+ "parsePath",
330
+ "allPath",
331
+ "not",
332
+ "object",
333
+ "viewProperty",
334
+ "pathTokens",
335
+ "leafToken",
336
+ "subPath",
337
+ "bindings",
338
+ "binds",
339
+ "named",
340
+ "bindto",
341
+ "_jsvto",
342
+ "bndCtx",
343
+ "bd",
344
+ "theOb",
345
+ "_jsv",
346
+ "sb",
347
+ "pathStart",
348
+ "parenDepth",
349
+ "expr",
350
+ "exprFn",
351
+ "newOb",
352
+ "aposed",
353
+ "quoted",
354
+ "boundName",
355
+ "bndStack",
356
+ "prm",
357
+ "tmplLinks",
358
+ "indexOf",
359
+ "paramIndex",
360
+ "split",
361
+ "join",
362
+ "rPath",
363
+ "fnCall",
364
+ "rParams",
365
+ "ast",
366
+ "node",
367
+ "hasTag",
368
+ "hasEncoder",
369
+ "getsVal",
370
+ "hasCnvt",
371
+ "useCnvt",
372
+ "tmplBindings",
373
+ "boundOnErrStart",
374
+ "boundOnErrEnd",
375
+ "tagRender",
376
+ "nestedTmpls",
377
+ "nestedTmpl",
378
+ "tagAndElses",
379
+ "nextIsElse",
380
+ "oldCode",
381
+ "isElse",
382
+ "isGetVal",
383
+ "tagCtxFn",
384
+ "tagStart",
385
+ "trigger",
386
+ "tmplBindingKey",
387
+ "templates",
388
+ "converters",
389
+ "code",
390
+ "tmplOptions",
391
+ "debug",
392
+ "Function",
393
+ "_tag",
394
+ "parentContext",
395
+ "getCharEntity",
396
+ "ch",
397
+ "charEntities",
398
+ "charCodeAt",
399
+ "getTargetProps",
400
+ "toJSON",
401
+ "$fnRender",
402
+ "tmplElem",
403
+ "jquery",
404
+ "selector",
405
+ "call",
406
+ "htmlEncode",
407
+ "text",
408
+ "rIsHtml",
409
+ "rHtmlEncode",
410
+ "setGlobals",
411
+ "jsvStoreName",
412
+ "versionNumber",
413
+ "rAttrEncode",
414
+ "&",
415
+ "<",
416
+ ">",
417
+ "",
418
+ "'",
419
+ """,
420
+ "`",
421
+ "jsr",
422
+ "jsrender",
423
+ "jsrToJq",
424
+ "jsviews",
425
+ "jsv",
426
+ "sub",
427
+ "parse",
428
+ "extend",
429
+ "syntaxErr",
430
+ "_ths",
431
+ "_cnvt",
432
+ "_err",
433
+ "Error",
434
+ "hlp",
435
+ "observable",
436
+ "renderFile",
437
+ "__express",
438
+ "isFunction",
439
+ "ob",
440
+ "Array",
441
+ "obj",
442
+ "_jq",
443
+ "jq",
444
+ "delimiters",
445
+ "if",
446
+ "done",
447
+ "selected",
448
+ "for",
449
+ "finalElse",
450
+ "include",
451
+ "*",
452
+ ":*",
453
+ "dbg",
454
+ "url",
455
+ "encodeURI"
456
+ ],
457
+ mappings: ";;CAaC,SAASA,GAET,GAAIC,IAAU,EAAGC,MAAM,QACtBC,EAAIF,EAAOG,MAEU,mBAAXC,SAAyBA,OAAOC,IAC1CD,OAAOL,GACsB,gBAAZO,SACjBC,OAAOD,QAAUJ,EACdH,EAAQG,GACR,SAASA,GACV,GAAIA,IAAMA,EAAEM,GACX,KAAM,wBAEP,OAAOT,GAAQG,IAGjBH,GAAQ,IAKV,SAASG,GACT,YAgGA,SAASO,GAAiBC,EAAYC,GACrC,MAAO,YACN,GAAIC,GACHC,EAAMC,KACNC,EAAWF,EAAIG,IAKhB,OAHAH,GAAIG,KAAON,EACXE,EAAMD,EAAOM,MAAMJ,EAAKK,WACxBL,EAAIG,KAAOD,EACJH,GAIT,QAASO,GAAUT,EAAYC,GAc9B,MAXIS,GAAYT,KACfA,EAASF,EACNC,EAEEA,EAAWW,GACVX,EACAD,EAAiBa,EAAMZ,GAHxBY,EAIHX,GAEFA,EAAOU,GAAK,GAENV,EAGR,QAASY,GAAqBV,EAAKW,GAClC,IAAK,GAAIC,KAAQD,GAAOE,MACnBC,GAAaC,KAAKH,KACrBZ,EAAIY,GAAQN,EAAUN,EAAIY,GAAOD,EAAOE,MAAMD,KAOjD,QAASI,GAAOC,GACf,MAAOA,GAGR,QAASR,KACR,MAAO,GAGR,QAASS,GAASD,GAGjB,IAEC,KAAM,iBAEP,MAAOE,IACP,MAAOlB,MAAKE,KAAOF,KAAKmB,UAAUf,WAAaY,EAGhD,QAASI,GAAQC,GAChBC,GAAeC,SAAWF,KAAc,EAGzC,QAASG,GAAaC,GAGrBzB,KAAK0B,MA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MAHIkX,KACHF,GAAI/V,MAAMoW,IAAIgB,IAAIhb,GAEZA,GAAK2Z",
458
+ file: "jsrender.min.js",
459
+ sourcesContent: [
460
+ "/*! JsRender v1.0.0-rc.69 (Beta - Release Candidate): http://jsviews.com/#jsrender */ /*! **VERSION FOR WEB** (For NODE.JS see http://jsviews.com/download/jsrender-node.js) */ /* * Best-of-breed templating in browser or on Node.js. * Does not require jQuery, or HTML DOM * Integrates with JsViews (http://jsviews.com/#jsviews) * * Copyright 2015, Boris Moore * Released under the MIT License. */ //jshint -W018, -W041 (function(factory) { // global var is the this object, which is window when running in the usual browser environment var global = (0, eval)('this'), // jshint ignore:line $ = global.jQuery; if (typeof define === "function" && define.amd) { // AMD script loader, e.g. RequireJS define(factory); } else if (typeof exports === "object") { // CommonJS e.g. Browserify module.exports = $ ? factory($) : function($) { // If no global jQuery, take optional jQuery passed as parameter: require('jsrender')(jQuery) if ($ && !$.fn) { throw "Provide jQuery or null"; } return factory($); }; } else { // Browser using plain <script> tag factory(false); } } ( // factory (for jquery.views.js) function($) { "use strict"; //========================== Top-level vars ========================== // global var is the this object, which is window when running in the usual browser environment var global = (0, eval)('this'), // jshint ignore:line setGlobals = $ === false; // Only set globals if script block in browser (not AMD and not CommonJS) $ = $ && $.fn ? $ : global.jQuery; // $ is jQuery passed in by CommonJS loader (Browserify), or global jQuery. var versionNumber = "v1.0.0-beta", jsvStoreName, rTag, rTmplString, topView, $views, //TODO tmplFnsCache = {}, $isFunction, $isArray, $templates, $converters, $helpers, $tags, $sub, $viewsSettings, delimOpenChar0 = "{", delimOpenChar1 = "{", delimCloseChar0 = "}", delimCloseChar1 = "}", linkChar = "^", rPath = /^(!*?)(?:null|true|false|\d[\d.]*|([\w$]+|\.|~([\w$]+)|#(view|([\w$]+))?)([\w$.^]*?)(?:[.[^]([\w$]+)\]?)?)$/g, // not object helper view viewProperty pathTokens leafToken rParams = /(\()(?=\s*\()|(?:([([])\s*)?(?:(\^?)(!*?[#~]?[\w$.^]+)?\s*((\+\+|--)|\+|-|&&|\|\||===|!==|==|!=|<=|>=|[<>%*:?\/]|(=))\s*|(!*?[#~]?[\w$.^]+)([([])?)|(,\s*)|(\(?)\\?(?:(')|("))|(?:\s*(([)\]])(?=\s*[.^]|\s*$|[^\(\[])|[)\]])([([]?))|(\s+)/g, // lftPrn0 lftPrn bound path operator err eq path2 prn comma lftPrn2 apos quot rtPrn rtPrnDot prn2 space // (left paren? followed by (path? followed by operator) or (path followed by left paren?)) or comma or apos or quot or right paren or space isRenderCall, rNewLine = /[ \t]*(\r\n|\n|\r)/g, rUnescapeQuotes = /\\(['"])/g, rEscapeQuotes = /['"\\]/g, // Escape quotes and \ character rBuildHash = /(?:\x08|^)(onerror:)?(?:(~?)(([\w$_\.]+):)?([^\x08]+))\x08(,)?([^\x08]+)/gi, rTestElseIf = /^if\s/, rFirstElem = /<(\w+)[>\s]/, rAttrEncode = /[\x00`><"'&]/g, // Includes > encoding since rConvertMarkers in JsViews does not skip > characters in attribute strings rIsHtml = /[\x00`><\"'&]/, rHasHandlers = /^on[A-Z]|^convert(Back)?$/, rHtmlEncode = rAttrEncode, viewId = 0, charEntities = { "&": "&amp;", "<": "&lt;", ">": "&gt;", "\x00": "&#0;", "'": "&#39;", '"': "&#34;", "`": "&#96;" }, HTML = "html", OBJECT = "object", tmplAttr = "data-jsv-tmpl", jsvTmpl = "jsvTmpl", indexStr = "For #index in nested block use #getIndex().", $render = {}, jsr = global.jsrender, jsrToJq = jsr && $ && !$.render, // JsRender already loaded, without jQuery. but we will re-load it now to attach to jQuery jsvStores = { template: { compile: compileTmpl }, tag: { compile: compileTag }, helper: {}, converter: {} }; // views object ($.views if jQuery is loaded, jsrender.views if no jQuery, e.g. in Node.js) $views = { jsviews: versionNumber, settings: function(settings) { $extend($viewsSettings, settings); dbgMode($viewsSettings._dbgMode); if ($viewsSettings.jsv) { $viewsSettings.jsv(); } }, sub: { // subscription, e.g. JsViews integration View: View, Err: JsViewsError, tmplFn: tmplFn, parse: parseParams, extend: $extend, extendCtx: extendCtx, syntaxErr: syntaxError, onStore: {}, _ths: tagHandlersFromProps, _tg: function() {} // Constructor for tagDef }, map: dataMap, // If jsObservable loaded first, use that definition of dataMap _cnvt: convertVal, _tag: renderTag, _err: error }; function getDerivedMethod(baseMethod, method) { return function() { var ret, tag = this, prevBase = tag.base; tag.base = baseMethod; // Within method call, calling this.base will call the base method ret = method.apply(tag, arguments); // Call the method tag.base = prevBase; // Replace this.base to be the base method of the previous call, for chained calls return ret; }; } function getMethod(baseMethod, method) { // For derived methods (or handlers declared declaratively as in {{:foo onChange=~fooChanged}} replace by a derived method, to allow using this.base(...) // or this.baseApply(arguments) to call the base implementation. (Equivalent to this._super(...) and this._superApply(arguments) in jQuery UI) if ($isFunction(method)) { method = getDerivedMethod( !baseMethod ? noop // no base method implementation, so use noop as base method : baseMethod._d ? baseMethod // baseMethod is a derived method, so us it : getDerivedMethod(noop, baseMethod), // baseMethod is not derived so make its base method be the noop method method ); method._d = 1; // Add flag that this is a derived method } return method; } function tagHandlersFromProps(tag, tagCtx) { for (var prop in tagCtx.props) { if (rHasHandlers.test(prop)) { tag[prop] = getMethod(tag[prop], tagCtx.props[prop]); // Copy over the onFoo props, convert and convertBack from tagCtx.props to tag (overrides values in tagDef). // Note: unsupported scenario: if handlers are dynamically added ^onFoo=expression this will work, but dynamically removing will not work. } } } function retVal(val) { return val; } function noop() { return ""; } function dbgBreak(val) { // Usage examples: {{dbg:...}}, {{:~dbg(...)}}, {{for ... onAfterLink=~dbg}}, {{dbg .../}} etc. // To break here, stop on caught exceptions. try { debugger; throw "dbg breakpoint"; } catch (e) {} return this.base ? this.baseApply(arguments) : val; } function dbgMode(debugMode) { $viewsSettings._dbgMode = debugMode !== false; // Pass in false to unset. Otherwise sets to true. } function JsViewsError(message) { // Error exception type for JsViews/JsRender // Override of $.views.sub.Error is possible this.name = ($.link ? "JsViews" : "JsRender") + " Error"; this.message = message || this.name; } function $extend(target, source) { var name; for (name in source) { target[name] = source[name]; } return target; } (JsViewsError.prototype = new Error()).constructor = JsViewsError; //========================== Top-level functions ========================== //=================== // views.delimiters //=================== function $viewsDelimiters(openChars, closeChars, link) { // Set the tag opening and closing delimiters and 'link' character. Default is "{{", "}}" and "^" // openChars, closeChars: opening and closing strings, each with two characters if (this !== 0 || openChars) { delimOpenChar0 = openChars ? openChars.charAt(0) : delimOpenChar0; // Escape the characters - since they could be regex special characters delimOpenChar1 = openChars ? openChars.charAt(1) : delimOpenChar1; delimCloseChar0 = closeChars ? closeChars.charAt(0) : delimCloseChar0; delimCloseChar1 = closeChars ? closeChars.charAt(1) : delimCloseChar1; linkChar = link || linkChar; openChars = "\\" + delimOpenChar0 + "(\\" + linkChar + ")?\\" + delimOpenChar1; // Default is "{^{" closeChars = "\\" + delimCloseChar0 + "\\" + delimCloseChar1; // Default is "}}" // Build regex with new delimiters // tag (followed by / space or }) or cvtr+colon or html or code rTag = "(?:(?:(\\w+(?=[\\/\\s\\" + delimCloseChar0 + "]))|(?:(\\w+)?(:)|(>)|!--((?:[^-]|-(?!-))*)--|(\\*)))" + "\\s*((?:[^\\" + delimCloseChar0 + "]|\\" + delimCloseChar0 + "(?!\\" + delimCloseChar1 + "))*?)"; // make rTag available to JsViews (or other components) for parsing binding expressions $sub.rTag = rTag + ")"; rTag = new RegExp(openChars + rTag + "(\\/)?|(?:\\/(\\w+)))" + closeChars, "g"); // Default: bind tag converter colon html comment code params slash closeBlock // /{(\^)?{(?:(?:(\w+(?=[\/\s}]))|(?:(\w+)?(:)|(>)|!--((?:[^-]|-(?!-))*)--|(\*)))\s*((?:[^}]|}(?!}))*?)(\/)?|(?:\/(\w+)))}}/g rTmplString = new RegExp("<.*>|([^\\\\]|^)[{}]|" + openChars + ".*" + closeChars); // rTmplString looks for html tags or { or } char not preceded by \\, or JsRender tags {{xxx}}. Each of these strings are considered // NOT to be jQuery selectors } return [delimOpenChar0, delimOpenChar1, delimCloseChar0, delimCloseChar1, linkChar]; } //========= // View.get //========= function getView(inner, type) { //view.get(inner, type) if (!type) { // view.get(type) type = inner; inner = undefined; } var views, i, l, found, view = this, root = !type || type === "root"; // If type is undefined, returns root view (view under top view). if (inner) { // Go through views - this one, and all nested ones, depth-first - and return first one with given type. found = view.type === type ? view : undefined; if (!found) { views = view.views; if (view._.useKey) { for (i in views) { if (found = views[i].get(inner, type)) { break; } } } else { for (i = 0, l = views.length; !found && i < l; i++) { found = views[i].get(inner, type); } } } } else if (root) { // Find root view. (view whose parent is top view) while (view.parent.parent) { found = view = view.parent; } } else { while (view && !found) { // Go through views - this one, and all parent ones - and return first one with given type. found = view.type === type ? view : undefined; view = view.parent; } } return found; } function getNestedIndex() { var view = this.get("item"); return view ? view.index : undefined; } getNestedIndex.depends = function() { return [this.get("item"), "index"]; }; function getIndex() { return this.index; } getIndex.depends = "index"; //========== // View.hlp //========== function getHelper(helper) { // Helper method called as view.hlp(key) from compiled template, for helper functions or template parameters ~foo var wrapped, view = this, ctx = view.linkCtx, res = (view.ctx || {})[helper]; if (res === undefined && ctx && ctx.ctx) { res = ctx.ctx[helper]; } if (res === undefined) { res = $helpers[helper]; } if (res) { if ($isFunction(res) && !res._wrp) { // If it is of type function, and not already wrapped, we will wrap it, so if called with no this pointer it will be called with the // view as 'this' context. If the helper ~foo() was in a data-link expression, the view will have a 'temporary' linkCtx property too. // Note that helper functions on deeper paths will have specific this pointers, from the preceding path. // For example, ~util.foo() will have the ~util object as 'this' pointer wrapped = function() { return res.apply((!this || this === global) ? view : this, arguments); }; wrapped._wrp = true; $extend(wrapped, res); // Attach same expandos (if any) to the wrapped function } } return wrapped || res; } //============== // views._cnvt //============== function convertVal(converter, view, tagCtx, onError) { // self is template object or linkCtx object var tag, value, // if tagCtx is an integer, then it is the key for the compiled function to return the boundTag tagCtx boundTag = typeof tagCtx === "number" && view.tmpl.bnds[tagCtx-1], linkCtx = view.linkCtx; // For data-link="{cvt:...}"... if (onError !== undefined) { tagCtx = onError = {props: {}, args: [onError]}; } else if (boundTag) { tagCtx = boundTag(view.data, view, $views); } value = tagCtx.args[0]; if (converter || boundTag) { tag = linkCtx && linkCtx.tag; if (!tag) { tag = $extend(new $sub._tg(), { _: { inline: !linkCtx, bnd: boundTag, unlinked: true }, tagName: ":", cvt: converter, flow: true, tagCtx: tagCtx, }); if (linkCtx) { linkCtx.tag = tag; tag.linkCtx = linkCtx; } tagCtx.ctx = extendCtx(tagCtx.ctx, (linkCtx ? linkCtx.view : view).ctx); } tag._er = onError && value; tagHandlersFromProps(tag, tagCtx); tagCtx.view = view; tag.ctx = tagCtx.ctx || {}; tagCtx.ctx = undefined; // Provide this tag on view, for addBindingMarkers on bound tags to add the tag to view._.bnds, associated with the tag id, view._.tag = tag; value = tag.cvtArgs(tag.convert || converter !== "true" && converter)[0]; // If there is a convertBack but no convert, converter will be "true" // Call onRender (used by JsViews if present, to add binding annotations around rendered content) value = boundTag && view._.onRender ? view._.onRender(value, view, boundTag) : value; view._.tag = undefined; } return value != undefined ? value : ""; } function convertArgs(converter) { var tag = this, tagCtx = tag.tagCtx, view = tagCtx.view, args = tagCtx.args; converter = tag.convert || converter; converter = converter && ("" + converter === converter ? (view.getRsc("converters", converter) || error("Unknown converter: '" + converter + "'")) : converter); args = !args.length && !tagCtx.index // On the opening tag with no args, bind to the current data context ? [view.data] : converter ? args.slice() // If there is a converter, use a copy of the tagCtx.args array for rendering, and replace the args[0] in // the copied array with the converted value. But we do not modify the value of tag.tagCtx.args[0] (the original args array) : args; // If no converter, get the original tagCtx.args if (converter) { if (converter.depends) { tag.depends = $sub.getDeps(tag.depends, tag, converter.depends, converter); } args[0] = converter.apply(tag, args); } return args; } //============= // views._tag //============= function getResource(resourceType, itemName) { var res, store, view = this; while ((res === undefined) && view) { store = view.tmpl && view.tmpl[resourceType]; res = store && store[itemName]; view = view.parent; } return res || $views[resourceType][itemName]; } function renderTag(tagName, parentView, tmpl, tagCtxs, isUpdate, onError) { parentView = parentView || topView; var tag, tag_, tagDef, template, tags, attr, parentTag, i, l, itemRet, tagCtx, tagCtxCtx, content, callInit, mapDef, thisMap, args, props, initialTmpl, tagDataMap, ret = "", linkCtx = parentView.linkCtx || 0, ctx = parentView.ctx, parentTmpl = tmpl || parentView.tmpl, // if tagCtx is an integer, then it is the key for the compiled function to return the boundTag tagCtxs boundTag = typeof tagCtxs === "number" && parentView.tmpl.bnds[tagCtxs-1]; if (tagName._is === "tag") { tag = tagName; tagName = tag.tagName; tagCtxs = tag.tagCtxs; template = tag.template; } else { tagDef = parentView.getRsc("tags", tagName) || error("Unknown tag: {{" + tagName + "}} "); template = tagDef.template; } if (onError !== undefined) { ret += onError; tagCtxs = onError = [{props: {}, args: []}]; } else if (boundTag) { tagCtxs = boundTag(parentView.data, parentView, $views); } l = tagCtxs.length; for (i = 0; i < l; i++) { tagCtx = tagCtxs[i]; if (!linkCtx || !linkCtx.tag || i && !linkCtx.tag._.inline || tag._er) { // Initialize tagCtx // For block tags, tagCtx.tmpl is an integer > 0 if (content = tagCtx.tmpl) { content = tagCtx.content = parentTmpl.tmpls[content - 1]; } tagCtx.index = i; tagCtx.tmpl = template || content; // Set the tmpl property to the content of the block tag tagCtx.render = renderContent; tagCtx.view = parentView; tagCtx.ctx = extendCtx(tagCtx.ctx, ctx); // Clone and extend parentView.ctx } if (tmpl = tagCtx.props.tmpl) { // If the tmpl property is overridden, set the value (when initializing, or, in case of binding: ^tmpl=..., when updating) tmpl = "" + tmpl === tmpl // if a string ? parentView.getRsc("templates", tmpl) || $templates(tmpl) : tmpl; tagCtx.tmpl = tmpl; } if (!tag) { // This will only be hit for initial tagCtx (not for {{else}}) - if the tag instance does not exist yet // Instantiate tag if it does not yet exist // If the tag has not already been instantiated, we will create a new instance. // ~tag will access the tag, even within the rendering of the template content of this tag. // From child/descendant tags, can access using ~tag.parent, or ~parentTags.tagName tag = new tagDef._ctr(); callInit = !!tag.init; tag.parent = parentTag = ctx && ctx.tag; tag.tagCtxs = tagCtxs; tagDataMap = tag.dataMap; if (linkCtx) { tag._.inline = false; linkCtx.tag = tag; tag.linkCtx = linkCtx; } if (tag._.bnd = boundTag || linkCtx.fn) { // Bound if {^{tag...}} or data-link="{tag...}" tag._.arrVws = {}; } else if (tag.dataBoundOnly) { error("{^{" + tagName + "}} tag must be data-bound"); } //TODO better perf for childTags() - keep child tag.tags array, (and remove child, when disposed) // tag.tags = []; } tagCtxs = tag.tagCtxs; tagDataMap = tag.dataMap; tagCtx.tag = tag; if (tagDataMap && tagCtxs) { tagCtx.map = tagCtxs[i].map; // Copy over the compiled map instance from the previous tagCtxs to the refreshed ones } if (!tag.flow) { tagCtxCtx = tagCtx.ctx = tagCtx.ctx || {}; // tags hash: tag.ctx.tags, merged with parentView.ctx.tags, tags = tag.parents = tagCtxCtx.parentTags = ctx && extendCtx(tagCtxCtx.parentTags, ctx.parentTags) || {}; if (parentTag) { tags[parentTag.tagName] = parentTag; //TODO better perf for childTags: parentTag.tags.push(tag); } tags[tag.tagName] = tagCtxCtx.tag = tag; } } if (boundTag || linkCtx) { // Provide this tag on view, for addBindingMarkers on bound tags to add the tag to view._.bnds, associated with the tag id parentView._.tag = tag; } if (!(tag._er = onError)) { tagHandlersFromProps(tag, tagCtxs[0]); tag.rendering = {}; // Provide object for state during render calls to tag and elses. (Used by {{if}} and {{for}}...) for (i = 0; i < l; i++) { tagCtx = tag.tagCtx = tagCtxs[i]; props = tagCtx.props; args = tag.cvtArgs(); if (mapDef = props.dataMap || tagDataMap) { if (args.length || props.dataMap) { thisMap = tagCtx.map; if (!thisMap || thisMap.src !== args[0] || isUpdate) { if (thisMap && thisMap.src) { thisMap.unmap(); // only called if observable map - not when only used in JsRender, e.g. by {{props}} } thisMap = tagCtx.map = mapDef.map(args[0], props, undefined, !tag._.bnd); } args = [thisMap.tgt]; } } tag.ctx = tagCtx.ctx; if (!i) { if (callInit) { initialTmpl = tag.template; tag.init(tagCtx, linkCtx, tag.ctx); callInit = undefined; if (tag.template !== initialTmpl) { tag._.tmpl = tag.template; // This will override the tag.template and also tagCtx.props.tmpl for all tagCtxs } } if (linkCtx) { // Set attr on linkCtx to ensure outputting to the correct target attribute. // Setting either linkCtx.attr or this.attr in the init() allows per-instance choice of target attrib. linkCtx.attr = tag.attr = linkCtx.attr || tag.attr; } attr = tag.attr; tag._.noVws = attr && attr !== HTML; } itemRet = undefined; if (tag.render) { itemRet = tag.render.apply(tag, args); } if (!args.length) { args = [parentView]; // no arguments - get data context from view. } if (itemRet === undefined) { itemRet = tagCtx.render(args.length ? args[0] : parentView, true) || (isUpdate ? undefined : ""); } // No return value from render, and no template/content tagCtx.render(...), so return undefined ret = ret ? ret + (itemRet || "") : itemRet; // If no rendered content, this will be undefined } tag.rendering = undefined; } tag.tagCtx = tagCtxs[0]; tag.ctx = tag.tagCtx.ctx; if (tag._.noVws) { if (tag._.inline) { // inline tag with attr set to "text" will insert HTML-encoded content - as if it was element-based innerText ret = attr === "text" ? $converters.html(ret) : ""; } } return boundTag && parentView._.onRender // Call onRender (used by JsViews if present, to add binding annotations around rendered content) ? parentView._.onRender(ret, parentView, boundTag) : ret; } //================= // View constructor //================= function View(context, type, parentView, data, template, key, contentTmpl, onRender) { // Constructor for view object in view hierarchy. (Augmented by JsViews if JsViews is loaded) var views, parentView_, tag, self_, self = this, isArray = type === "array"; self.content = contentTmpl; self.views = isArray ? [] : {}; self.parent = parentView; self.type = type || "top"; self.data = data; self.tmpl = template; // If the data is an array, this is an 'array view' with a views array for each child 'item view' // If the data is not an array, this is an 'item view' with a views 'hash' object for any child nested views // ._.useKey is non zero if is not an 'array view' (owning a data array). Use this as next key for adding to child views hash self_ = self._ = { key: 0, useKey: isArray ? 0 : 1, id: "" + viewId++, onRender: onRender, bnds: {} }; self.linked = !!onRender; if (parentView) { views = parentView.views; parentView_ = parentView._; if (parentView_.useKey) { // Parent is an 'item view'. Add this view to its views object // self._key = is the key in the parent view hash views[self_.key = "_" + parentView_.useKey++] = self; self.index = indexStr; self.getIndex = getNestedIndex; tag = parentView_.tag; self_.bnd = isArray && (!tag || !!tag._.bnd && tag); // For array views that are data bound for collection change events, set the // view._.bnd property to true for top-level link() or data-link="{for}", or to the tag instance for a data-bound tag, e.g. {^{for ...}} } else if (views.length === (self_.key = self.index = key)) { // Parent is an 'array view'. Add this view to its views array views.push(self); // Use push when possible (better perf than splice) } else { views.splice(key, 0, self); } // If no context was passed in, use parent context // If context was passed in, it should have been merged already with parent context self.ctx = context || parentView.ctx; } else { self.ctx = context; } } View.prototype = { get: getView, getIndex: getIndex, getRsc: getResource, hlp: getHelper, _is: "view" }; //============= // Registration //============= function compileChildResources(parentTmpl) { var storeName, resources, resourceName, resource, settings, compile, onStore; for (storeName in jsvStores) { settings = jsvStores[storeName]; if ((compile = settings.compile) && (resources = parentTmpl[storeName + "s"])) { for (resourceName in resources) { // compile child resource declarations (templates, tags, tags["for"] or helpers) resource = resources[resourceName] = compile(resourceName, resources[resourceName], parentTmpl, 0); resource._is = storeName; // Only do this for compiled objects (tags, templates...) if (resource && (onStore = $sub.onStore[storeName])) { // e.g. JsViews integration onStore(resourceName, resource, compile); } } } } } function compileTag(name, tagDef, parentTmpl) { var tmpl, baseTag, prop, compiledDef = new $sub._tg(); function Tag() { var tag = this; tag._ = { inline: true, unlinked: true }; tag.tagName = name; } if ($isFunction(tagDef)) { // Simple tag declared as function. No presenter instantation. tagDef = { depends: tagDef.depends, render: tagDef }; } else if ("" + tagDef === tagDef) { tagDef = {template: tagDef}; } if (baseTag = tagDef.baseTag) { tagDef.flow = !!tagDef.flow; // Set flow property, so defaults to false even if baseTag has flow=true tagDef.baseTag = baseTag = "" + baseTag === baseTag ? (parentTmpl && parentTmpl.tags[baseTag] || $tags[baseTag]) : baseTag; compiledDef = $extend(compiledDef, baseTag); for (prop in tagDef) { compiledDef[prop] = getMethod(baseTag[prop], tagDef[prop]); } } else { compiledDef = $extend(compiledDef, tagDef); } // Tag declared as object, used as the prototype for tag instantiation (control/presenter) if ((tmpl = compiledDef.template) !== undefined) { compiledDef.template = "" + tmpl === tmpl ? ($templates[tmpl] || $templates(tmpl)) : tmpl; } if (compiledDef.init !== false) { // Set init: false on tagDef if you want to provide just a render method, or render and template, but no constuctor or prototype. // so equivalent to setting tag to render function, except you can also provide a template. (Tag.prototype = compiledDef).constructor = compiledDef._ctr = Tag; } if (parentTmpl) { compiledDef._parentTmpl = parentTmpl; } return compiledDef; } function baseApply(args) { // In derived method (or handler declared declaratively as in {{:foo onChange=~fooChanged}} can call base method, // using this.baseApply(arguments) (Equivalent to this._superApply(arguments) in jQuery UI) return this.base.apply(this, args); } function compileTmpl(name, tmpl, parentTmpl, options) { // tmpl is either a template object, a selector for a template script block, the name of a compiled template, or a template object //==== nested functions ==== function lookupTemplate(value) { // If value is of type string - treat as selector, or name of compiled template // Return the template object, if already compiled, or the markup string var currentName, tmpl; if (("" + value === value) || value.nodeType > 0 && (elem = value)) { if (!elem) { if (/^\.\/[^\\:*?"<>]*$/.test(value)) { // tmpl="./some/file.html" // If the template is not named, use "./some/file.html" as name. if (tmpl = $templates[name = name || value]) { value = tmpl; } else { // BROWSER-SPECIFIC CODE (not on Node.js): // Look for server-generated script block with id "./some/file.html" elem = document.getElementById(value); } } else if ($.fn && !rTmplString.test(value)) { try { elem = $(document).find(value)[0]; // if jQuery is loaded, test for selector returning elements, and get first element } catch (e) {} }// END BROWSER-SPECIFIC CODE } //BROWSER-SPECIFIC CODE if (elem) { // Generally this is a script element. // However we allow it to be any element, so you can for example take the content of a div, // use it as a template, and replace it by the same content rendered against data. // e.g. for linking the content of a div to a container, and using the initial content as template: // $.link("#content", model, {tmpl: "#content"}); if (options) { // We will compile a new template using the markup in the script element value = elem.innerHTML; } else { // We will cache a single copy of the compiled template, and associate it with the name // (renaming from a previous name if there was one). currentName = elem.getAttribute(tmplAttr); if (currentName) { if (currentName !== jsvTmpl) { value = $templates[currentName]; delete $templates[currentName]; } else if ($.fn) { value = $.data(elem)[jsvTmpl]; } } else { name = name || ($.fn ? jsvTmpl : value); value = compileTmpl(name, elem.innerHTML, parentTmpl, options); } value.tmplName = name = name || currentName; if (name !== jsvTmpl) { $templates[name] = value; } elem.setAttribute(tmplAttr, name); if ($.fn) { $.data(elem, jsvTmpl, value); } } } // END BROWSER-SPECIFIC CODE elem = undefined; } else if (!value.fn) { value = undefined; // If value is not a string. HTML element, or compiled template, return undefined } return value; } var elem, compiledTmpl, tmplOrMarkup = tmpl = tmpl || ""; //==== Compile the template ==== if (options === 0) { options = undefined; tmplOrMarkup = lookupTemplate(tmplOrMarkup); // Top-level compile so do a template lookup } // If options, then this was already compiled from a (script) element template declaration. // If not, then if tmpl is a template object, use it for options options = options || (tmpl.markup ? tmpl : {}); options.tmplName = name; if (parentTmpl) { options._parentTmpl = parentTmpl; } // If tmpl is not a markup string or a selector string, then it must be a template object // In that case, get it from the markup property of the object if (!tmplOrMarkup && tmpl.markup && (tmplOrMarkup = lookupTemplate(tmpl.markup))) { if (tmplOrMarkup.fn) { // If the string references a compiled template object, need to recompile to merge any modified options tmplOrMarkup = tmplOrMarkup.markup; } } if (tmplOrMarkup !== undefined) { if (tmplOrMarkup.fn || tmpl.fn) { // tmpl is already compiled, so use it if (tmplOrMarkup.fn) { compiledTmpl = tmplOrMarkup; } } else { // tmplOrMarkup is a markup string, not a compiled template // Create template object tmpl = tmplObject(tmplOrMarkup, options); // Compile to AST and then to compiled function tmplFn(tmplOrMarkup.replace(rEscapeQuotes, "\\$&"), tmpl); } if (!compiledTmpl) { compileChildResources(options); compiledTmpl = $extend(function() { return tmpl.render.apply(tmpl, arguments); }, tmpl); } if (name && !parentTmpl && name !== jsvTmpl) { $render[name] = compiledTmpl; } return compiledTmpl; } } //==== /end of function compileTmpl ==== function dataMap(mapDef) { function Map(source, options) { this.tgt = mapDef.getTgt(source, options); } if ($isFunction(mapDef)) { // Simple map declared as function mapDef = { getTgt: mapDef }; } if (mapDef.baseMap) { mapDef = $extend($extend({}, mapDef.baseMap), mapDef); } mapDef.map = function(source, options) { return new Map(source, options); }; return mapDef; } function tmplObject(markup, options) { // Template object constructor var htmlTag, wrapMap = $viewsSettings.wrapMap || {}, // Only used in JsViews. Otherwise empty: {} tmpl = $extend( { tmpls: [], links: {}, // Compiled functions for link expressions bnds: [], _is: "template", render: renderContent }, options ); tmpl.markup = markup; if (!options.htmlTag) { // Set tmpl.tag to the top-level HTML tag used in the template, if any... htmlTag = rFirstElem.exec(markup); tmpl.htmlTag = htmlTag ? htmlTag[1].toLowerCase() : ""; } htmlTag = wrapMap[tmpl.htmlTag]; if (htmlTag && htmlTag !== wrapMap.div) { // When using JsViews, we trim templates which are inserted into HTML contexts where text nodes are not rendered (i.e. not 'Phrasing Content'). // Currently not trimmed for <li> tag. (Not worth adding perf cost) tmpl.markup = $.trim(tmpl.markup); } return tmpl; } function registerStore(storeName, storeSettings) { function theStore(name, item, parentTmpl) { // The store is also the function used to add items to the store. e.g. $.templates, or $.views.tags // For store of name 'thing', Call as: // $.views.things(items[, parentTmpl]), // or $.views.things(name, item[, parentTmpl]) var onStore, compile, itemName, thisStore; if (name && typeof name === OBJECT && !name.nodeType && !name.markup && !name.getTgt) { // Call to $.views.things(items[, parentTmpl]), // Adding items to the store // If name is a hash, then item is parentTmpl. Iterate over hash and call store for key. for (itemName in name) { theStore(itemName, name[itemName], item); } return $views; } // Adding a single unnamed item to the store if (item === undefined) { item = name; name = undefined; } if (name && "" + name !== name) { // name must be a string parentTmpl = item; item = name; name = undefined; } thisStore = parentTmpl ? parentTmpl[storeNames] = parentTmpl[storeNames] || {} : theStore; compile = storeSettings.compile; if (item === null) { // If item is null, delete this entry if (name) { delete thisStore[name]; } } else { item = compile ? compile(name, item, parentTmpl, 0) : item; if (name) { thisStore[name] = item; } } if (compile && item) { item._is = storeName; // Only do this for compiled objects (tags, templates...) } if (item && (onStore = $sub.onStore[storeName])) { // e.g. JsViews integration onStore(name, item, compile); } return item; } var storeNames = storeName + "s"; $views[storeNames] = theStore; } //============== // renderContent //============== function renderContent(data, context, noIteration, parentView, key, onRender) { var i, l, tag, tmpl, tagCtx, isTopRenderCall, prevData, prevIndex, view = parentView, result = ""; if (context === true) { noIteration = context; // passing boolean as second param - noIteration context = undefined; } else if (typeof context !== OBJECT) { context = undefined; // context must be a boolean (noIteration) or a plain object } if (tag = this.tag) { // This is a call from renderTag or tagCtx.render(...) tagCtx = this; tmpl = tag._.tmpl || tagCtx.tmpl; view = view || tagCtx.view; if (!arguments.length) { data = view; } } else { // This is a template.render(...) call tmpl = this; } if (tmpl) { if (!view && data && data._is === "view") { view = data; // When passing in a view to render or link (and not passing in a parent view) use the passed-in view as parentView } if (view) { if (data === view) { // Inherit the data from the parent view. // This may be the contents of an {{if}} block data = view.data; } } if (!tmpl.fn) { // Template has not been compiled yet, so compile it. tmpl = tag._.tmpl = $templates[tmpl] || $templates(tmpl); } isTopRenderCall = !view; isRenderCall = isRenderCall || isTopRenderCall; if (!view) { (context = context || {}).root = data; // Provide ~root as shortcut to top-level data. } if (!isRenderCall || $viewsSettings.useViews || tmpl.useViews || view && view !== topView) { result = renderWithViews(tmpl, data, context, noIteration, view, key, onRender, tag); } else { if (view) { // In a block prevData = view.data; prevIndex = view.index; view.index = indexStr; } else { view = topView; view.data = data; view.ctx = context; } if ($isArray(data) && !noIteration) { // Create a view for the array, whose child views correspond to each data item. (Note: if key and parentView are passed in // along with parent view, treat as insert -e.g. from view.addViews - so parentView is already the view item for array) for (i = 0, l = data.length; i < l; i++) { view.index = i; view.data = data[i]; result += tmpl.fn(data[i], view, $views); } } else { result += tmpl.fn(data, view, $views); } view.data = prevData; view.index = prevIndex; } if (isTopRenderCall) { isRenderCall = undefined; } } return result; } function renderWithViews(tmpl, data, context, noIteration, view, key, onRender, tag) { function setItemVar(item) { // When itemVar is specified, set modified ctx with user-named ~item newCtx = $extend({}, context); newCtx[itemVar] = item; } // Render template against data as a tree of subviews (nested rendered template instances), or as a string (top-level template). // If the data is the parent view, treat as noIteration, re-render with the same data context. var i, l, newView, childView, itemResult, swapContent, contentTmpl, outerOnRender, tmplName, itemVar, newCtx, tagCtx, result="" ; if (tag) { // This is a call from renderTag or tagCtx.render(...) tmplName = tag.tagName; tagCtx = tag.tagCtx; context = context ? extendCtx(context, tag.ctx) : tag.ctx; contentTmpl = tagCtx.content; if (tagCtx.props.link === false) { // link=false setting on block tag // We will override inherited value of link by the explicit setting link=false taken from props // The child views of an unlinked view are also unlinked. So setting child back to true will not have any effect. context = context || {}; context.link = false; } if (itemVar = tagCtx.props.itemVar) { if (itemVar.charAt(0) !== "~") { syntaxError("Use itemVar='~myItem'"); } itemVar = itemVar.slice(1); } } if (view) { contentTmpl = contentTmpl || view.content; // The wrapped content - to be added as #content property on views, below onRender = onRender || view._.onRender; context = extendCtx(context, view.ctx); } if (key === true) { swapContent = true; key = 0; } // If link===false, do not call onRender, so no data-linking marker nodes if (onRender && (context && context.link === false || tag && tag._.noVws)) { onRender = undefined; } outerOnRender = onRender; if (onRender === true) { // Used by view.refresh(). Don't create a new wrapper view. outerOnRender = undefined; onRender = view._.onRender; } // Set additional context on views created here, (as modified context inherited from the parent, and to be inherited by child views) context = tmpl.helpers ? extendCtx(tmpl.helpers, context) : context; newCtx = context; if ($isArray(data) && !noIteration) { // Create a view for the array, whose child views correspond to each data item. (Note: if key and view are passed in // along with parent view, treat as insert -e.g. from view.addViews - so view is already the view item for array) newView = swapContent ? view : (key !== undefined && view) || new View(context, "array", view, data, tmpl, key, contentTmpl, onRender); if (itemVar) { newView.it = itemVar; } itemVar = newView.it; for (i = 0, l = data.length; i < l; i++) { // Create a view for each data item. if (itemVar) { setItemVar(data[i]); // use modified ctx with user-named ~item } childView = new View(newCtx, "item", newView, data[i], tmpl, (key || 0) + i, contentTmpl, onRender); itemResult = tmpl.fn(data[i], childView, $views); result += newView._.onRender ? newView._.onRender(itemResult, childView) : itemResult; } } else { // Create a view for singleton data object. The type of the view will be the tag name, e.g. "if" or "myTag" except for // "item", "array" and "data" views. A "data" view is from programmatic render(object) against a 'singleton'. if (itemVar) { setItemVar(data); } newView = swapContent ? view : new View(newCtx, tmplName || "data", view, data, tmpl, key, contentTmpl, onRender); if (tag && !tag.flow) { newView.tag = tag; } result += tmpl.fn(data, newView, $views); } return outerOnRender ? outerOnRender(result, newView) : result; } //=========================== // Build and compile template //=========================== // Generate a reusable function that will serve to render a template against data // (Compile AST then build template function) function error(e, view, fallback) { var message = $viewsSettings.onError(e, view, fallback); if ("" + e === e) { // if e is a string, not an Exception, then throw new Exception throw new $sub.Err(message); } return !view.linkCtx && view.linked ? $converters.html(message) : message; } function syntaxError(message) { error("Syntax error\n" + message); } function tmplFn(markup, tmpl, isLinkExpr, convertBack, hasElse) { // Compile markup to AST (abtract syntax tree) then build the template function code from the AST nodes // Used for compiling templates, and also by JsViews to build functions for data link expressions //==== nested functions ==== function pushprecedingContent(shift) { shift -= loc; if (shift) { content.push(markup.substr(loc, shift).replace(rNewLine, "\\n")); } } function blockTagCheck(tagName, block) { if (tagName) { tagName += '}}'; // '{{include}} block has {{/for}} with no open {{for}}' syntaxError(( block ? '{{' + block + '}} block has {{/' + tagName + ' without {{' + tagName : 'Unmatched or missing {{/' + tagName) + ', in template:\n' + markup); } } function parseTag(all, bind, tagName, converter, colon, html, comment, codeTag, params, slash, closeBlock, index) { // bind tag converter colon html comment code params slash closeBlock // /{(\^)?{(?:(?:(\w+(?=[\/\s}]))|(?:(\w+)?(:)|(>)|!--((?:[^-]|-(?!-))*)--|(\*)))\s*((?:[^}]|}(?!}))*?)(\/)?|(?:\/(\w+)))}}/g // Build abstract syntax tree (AST): [tagName, converter, params, content, hash, bindings, contentMarkup] if (html) { colon = ":"; converter = HTML; } slash = slash || isLinkExpr && !hasElse; var pathBindings = (bind || isLinkExpr) && [[]], props = "", args = "", ctxProps = "", paramsArgs = "", paramsProps = "", paramsCtxProps = "", onError = "", useTrigger = "", // Block tag if not self-closing and not {{:}} or {{>}} (special case) and not a data-link expression block = !slash && !colon && !comment; //==== nested helper function ==== tagName = tagName || (params = params || "#data", colon); // {{:}} is equivalent to {{:#data}} pushprecedingContent(index); loc = index + all.length; // location marker - parsed up to here if (codeTag) { if (allowCode) { content.push(["*", "\n" + params.replace(/^:/, "ret+= ").replace(rUnescapeQuotes, "$1") + ";\n"]); } } else if (tagName) { if (tagName === "else") { if (rTestElseIf.test(params)) { syntaxError('for "{{else if expr}}" use "{{else expr}}"'); } pathBindings = current[7] && [[]]; current[8] = markup.substring(current[8], index); // contentMarkup for block tag current = stack.pop(); content = current[2]; block = true; } if (params) { // remove newlines from the params string, to avoid compiled code errors for unterminated strings parseParams(params.replace(rNewLine, " "), pathBindings, tmpl) .replace(rBuildHash, function(all, onerror, isCtx, key, keyToken, keyValue, arg, param) { key = "'" + keyToken + "':"; if (arg) { args += keyValue + ","; paramsArgs += "'" + param + "',"; } else if (isCtx) { ctxProps += key + keyValue + ","; paramsCtxProps += key + "'" + param + "',"; } else if (onerror) { onError += keyValue; } else { if (keyToken === "trigger") { useTrigger += keyValue; } props += key + keyValue + ","; paramsProps += key + "'" + param + "',"; hasHandlers = hasHandlers || rHasHandlers.test(keyToken); } return ""; }).slice(0, -1); } if (pathBindings && pathBindings[0]) { pathBindings.pop(); // Remove the bindings that was prepared for next arg. (There is always an extra one ready). } newNode = [ tagName, converter || !!convertBack || hasHandlers || "", block && [], parsedParam(paramsArgs, paramsProps, paramsCtxProps), parsedParam(args, props, ctxProps), onError, useTrigger, pathBindings || 0 ]; content.push(newNode); if (block) { stack.push(current); current = newNode; current[8] = loc; // Store current location of open tag, to be able to add contentMarkup when we reach closing tag } } else if (closeBlock) { blockTagCheck(closeBlock !== current[0] && current[0] !== "else" && closeBlock, current[0]); current[8] = markup.substring(current[8], index); // contentMarkup for block tag current = stack.pop(); } blockTagCheck(!current && closeBlock); content = current[2]; } //==== /end of nested functions ==== var result, newNode, hasHandlers, allowCode = $viewsSettings.allowCode || tmpl && tmpl.allowCode, astTop = [], loc = 0, stack = [], content = astTop, current = [,,astTop]; if (allowCode) { tmpl.allowCode = allowCode; } //TODO result = tmplFnsCache[markup]; // Only cache if template is not named and markup length < ..., //and there are no bindings or subtemplates?? Consider standard optimization for data-link="a.b.c" // if (result) { // tmpl.fn = result; // } else { // result = markup; if (isLinkExpr) { markup = delimOpenChar0 + markup + delimCloseChar1; } blockTagCheck(stack[0] && stack[0][2].pop()[0]); // Build the AST (abstract syntax tree) under astTop markup.replace(rTag, parseTag); pushprecedingContent(markup.length); if (loc = astTop[astTop.length - 1]) { blockTagCheck("" + loc !== loc && (+loc[8] === loc[8]) && loc[0]); } // result = tmplFnsCache[markup] = buildCode(astTop, tmpl); // } if (isLinkExpr) { result = buildCode(astTop, markup, isLinkExpr); setPaths(result, [astTop[0][7]]); // With data-link expressions, pathBindings array is astTop[0][7] } else { result = buildCode(astTop, tmpl); } return result; } function setPaths(fn, pathsArr) { var key, paths, i = 0, l = pathsArr.length; fn.deps = []; for (; i < l; i++) { paths = pathsArr[i]; for (key in paths) { if (key !== "_jsvto" && paths[key].length) { fn.deps = fn.deps.concat(paths[key]); // deps is the concatenation of the paths arrays for the different bindings } } } fn.paths = paths; // The array of paths arrays for the different bindings } function parsedParam(args, props, ctx) { return [args.slice(0, -1), props.slice(0, -1), ctx.slice(0, -1)]; } function paramStructure(parts, type) { return '\n\t' + (type ? type + ':{' : '') + 'args:[' + parts[0] + ']' + (parts[1] || !type ? ',\n\tprops:{' + parts[1] + '}' : "") + (parts[2] ? ',\n\tctx:{' + parts[2] + '}' : ""); } function parseParams(params, pathBindings, tmpl) { function parseTokens(all, lftPrn0, lftPrn, bound, path, operator, err, eq, path2, prn, comma, lftPrn2, apos, quot, rtPrn, rtPrnDot, prn2, space, index, full) { // /(\()(?=\s*\()|(?:([([])\s*)?(?:(\^?)(!*?[#~]?[\w$.^]+)?\s*((\+\+|--)|\+|-|&&|\|\||===|!==|==|!=|<=|>=|[<>%*:?\/]|(=))\s*|(!*?[#~]?[\w$.^]+)([([])?)|(,\s*)|(\(?)\\?(?:(')|("))|(?:\s*(([)\]])(?=\s*[.^]|\s*$|\s)|[)\]])([([]?))|(\s+)/g, // lftPrn0 lftPrn bound path operator err eq path2 prn comma lftPrn2 apos quot rtPrn rtPrnDot prn2 space // (left paren? followed by (path? followed by operator) or (path followed by paren?)) or comma or apos or quot or right paren or space bound = bindings && bound; if (bound && !eq) { path = bound + path; // e.g. some.fn(...)^some.path - so here path is "^some.path" } operator = operator || ""; lftPrn = lftPrn || lftPrn0 || lftPrn2; path = path || path2; // Could do this - but not worth perf cost?? :- // if (!path.lastIndexOf("#data.", 0)) { path = path.slice(6); } // If path starts with "#data.", remove that. prn = prn || prn2 || ""; var expr, exprFn, binds, theOb, newOb; function parsePath(allPath, not, object, helper, view, viewProperty, pathTokens, leafToken) { // rPath = /^(?:null|true|false|\d[\d.]*|(!*?)([\w$]+|\.|~([\w$]+)|#(view|([\w$]+))?)([\w$.^]*?)(?:[.[^]([\w$]+)\]?)?)$/g, // none object helper view viewProperty pathTokens leafToken var subPath = object === "."; if (object) { path = path.slice(not.length); if (!subPath) { allPath = (helper ? 'view.hlp("' + helper + '")' : view ? "view" : "data") + (leafToken ? (viewProperty ? "." + viewProperty : helper ? "" : (view ? "" : "." + object) ) + (pathTokens || "") : (leafToken = helper ? "" : view ? viewProperty || "" : object, "")); allPath = allPath + (leafToken ? "." + leafToken : ""); allPath = not + (allPath.slice(0, 9) === "view.data" ? allPath.slice(5) // convert #view.data... to data... : allPath); } if (bindings) { binds = named === "linkTo" ? (bindto = pathBindings._jsvto = pathBindings._jsvto || []) : bndCtx.bd; if (theOb = subPath && binds[binds.length-1]) { if (theOb._jsv) { while (theOb.sb) { theOb = theOb.sb; } if (theOb.bnd) { path = "^" + path.slice(1); } theOb.sb = path; theOb.bnd = theOb.bnd || path.charAt(0) === "^"; } } else { binds.push(path); } pathStart[parenDepth] = index + (subPath ? 1 : 0); } } return allPath; } if (err && !aposed && !quoted) { syntaxError(params); } else { if (bindings && rtPrnDot && !aposed && !quoted) { // This is a binding to a path in which an object is returned by a helper/data function/expression, e.g. foo()^x.y or (a?b:c)^x.y // We create a compiled function to get the object instance (which will be called when the dependent data of the subexpression changes, to return the new object, and trigger re-binding of the subsequent path) if (!named || boundName || bindto) { expr = pathStart[parenDepth - 1]; if (full.length - 1 > index - (expr || 0)) { // We need to compile a subexpression expr = full.slice(expr, index + all.length); if (exprFn !== true) { // If not reentrant call during compilation binds = bindto || bndStack[parenDepth-1].bd; // Insert exprOb object, to be used during binding to return the computed object theOb = binds[binds.length-1]; if (theOb && theOb.prm) { while (theOb.sb && theOb.sb.prm) { theOb = theOb.sb; } newOb = theOb.sb = {path: theOb.sb, bnd: theOb.bnd}; } else { binds.push(newOb = {path: binds.pop()}); // Insert exprOb object, to be used during binding to return the computed object } // (e.g. "some.object()" in "some.object().a.b" - to be used as context for binding the following tokens "a.b") } rtPrnDot = delimOpenChar1 + ":" + expr // The parameter or function subexpression + " onerror=''" // set onerror='' in order to wrap generated code with a try catch - returning '' as object instance if there is an error/missing parent + delimCloseChar0; exprFn = tmplLinks[rtPrnDot]; if (!exprFn) { tmplLinks[rtPrnDot] = true; // Flag that this exprFn (for rtPrnDot) is being compiled tmplLinks[rtPrnDot] = exprFn = tmplFn(rtPrnDot, tmpl, true); // Compile the expression (or use cached copy already in tmpl.links) } if (exprFn !== true && newOb) { // If not reentrant call during compilation newOb._jsv = exprFn; newOb.prm = bndCtx.bd; newOb.bnd = newOb.bnd || newOb.path && newOb.path.indexOf("^") >= 0; } } } } return (aposed // within single-quoted string ? (aposed = !apos, (aposed ? all : lftPrn2 + '"')) : quoted // within double-quoted string ? (quoted = !quot, (quoted ? all : lftPrn2 + '"')) : ( (lftPrn ? (pathStart[parenDepth] = index++, bndCtx = bndStack[++parenDepth] = {bd: []}, lftPrn) : "") + (space ? (parenDepth ? "" // New arg or prop - so insert backspace \b (\x08) as separator for named params, used subsequently by rBuildHash, and prepare new bindings array : (paramIndex = full.slice(paramIndex, index), named ? (named = boundName = bindto = false, "\b") : "\b,") + paramIndex + (paramIndex = index + all.length, bindings && pathBindings.push(bndCtx.bd = []), "\b") ) : eq // named param. Remove bindings for arg and create instead bindings array for prop ? (parenDepth && syntaxError(params), bindings && pathBindings.pop(), named = path, boundName = bound, paramIndex = index + all.length, bound && (bindings = bndCtx.bd = pathBindings[named] = []), path + ':') : path // path ? (path.split("^").join(".").replace(rPath, parsePath) + (prn // some.fncall( ? (bndCtx = bndStack[++parenDepth] = {bd: []}, fnCall[parenDepth] = true, prn) : operator) ) : operator // operator ? operator : rtPrn // function ? ((fnCall[parenDepth] = false, bndCtx = bndStack[--parenDepth], rtPrn) + (prn // rtPrn and prn, e.g )( in (a)() or a()(), or )[ in a()[] ? (bndCtx = bndStack[++parenDepth], fnCall[parenDepth] = true, prn) : "") ) : comma ? (fnCall[parenDepth] || syntaxError(params), ",") // We don't allow top-level literal arrays or objects : lftPrn0 ? "" : (aposed = apos, quoted = quot, '"') )) ); } } var named, bindto, boundName, quoted, // boolean for string content in double quotes aposed, // or in single quotes bindings = pathBindings && pathBindings[0], // bindings array for the first arg bndCtx = {bd: bindings}, bndStack = {0: bndCtx}, paramIndex = 0, // list, tmplLinks = tmpl ? tmpl.links : bindings && (bindings.links = bindings.links || {}), // The following are used for tracking path parsing including nested paths, such as "a.b(c^d + (e))^f", and chained computed paths such as // "a.b().c^d().e.f().g" - which has four chained paths, "a.b()", "^c.d()", ".e.f()" and ".g" parenDepth = 0, fnCall = {}, // We are in a function call pathStart = {}; // tracks the start of the current path such as c^d() in the above example return (params + (tmpl ? " " : "")) .replace(rParams, parseTokens); } function buildCode(ast, tmpl, isLinkExpr) { // Build the template function code from the AST nodes, and set as property on the passed-in template object // Used for compiling templates, and also by JsViews to build functions for data link expressions var i, node, tagName, converter, tagCtx, hasTag, hasEncoder, getsVal, hasCnvt, useCnvt, tmplBindings, pathBindings, params, boundOnErrStart, boundOnErrEnd, tagRender, nestedTmpls, tmplName, nestedTmpl, tagAndElses, content, markup, nextIsElse, oldCode, isElse, isGetVal, tagCtxFn, onError, tagStart, trigger, tmplBindingKey = 0, useViews = $viewsSettings.useViews || tmpl.useViews || tmpl.tags || tmpl.templates || tmpl.helpers || tmpl.converters, code = "", tmplOptions = {}, l = ast.length; if ("" + tmpl === tmpl) { tmplName = isLinkExpr ? 'data-link="' + tmpl.replace(rNewLine, " ").slice(1, -1) + '"' : tmpl; tmpl = 0; } else { tmplName = tmpl.tmplName || "unnamed"; if (tmpl.allowCode) { tmplOptions.allowCode = true; } if (tmpl.debug) { tmplOptions.debug = true; } tmplBindings = tmpl.bnds; nestedTmpls = tmpl.tmpls; } for (i = 0; i < l; i++) { // AST nodes: [0: tagName, 1: converter, 2: content, 3: params, 4: code, 5: onError, 6: trigger, 7:pathBindings, 8: contentMarkup] node = ast[i]; // Add newline for each callout to t() c() etc. and each markup string if ("" + node === node) { // a markup string to be inserted code += '\n+"' + node + '"'; } else { // a compiled tag expression to be inserted tagName = node[0]; if (tagName === "*") { // Code tag: {{* }} code += ";\n" + node[1] + "\nret=ret"; } else { converter = node[1]; content = !isLinkExpr && node[2]; tagCtx = paramStructure(node[3], 'params') + '},' + paramStructure(params = node[4]); onError = node[5]; trigger = node[6]; markup = node[8] && node[8].replace(rUnescapeQuotes, "$1"); if (isElse = tagName === "else") { if (pathBindings) { pathBindings.push(node[7]); } } else { tmplBindingKey = 0; if (tmplBindings && (pathBindings = node[7])) { // Array of paths, or false if not data-bound pathBindings = [pathBindings]; tmplBindingKey = tmplBindings.push(1); // Add placeholder in tmplBindings for compiled function } } useViews = useViews || params[1] || params[2] || pathBindings || /view.(?!index)/.test(params[0]); // useViews is for perf optimization. For render() we only use views if necessary - for the more advanced scenarios. // We use views if there are props, contextual properties or args with #... (other than #index) - but you can force // using the full view infrastructure, (and pay a perf price) by opting in: Set useViews: true on the template, manually... if (isGetVal = tagName === ":") { if (converter) { tagName = converter === HTML ? ">" : converter + tagName; } } else { if (content) { // TODO optimize - if content.length === 0 or if there is a tmpl="..." specified - set content to null / don't run this compilation code - since content won't get used!! // Create template object for nested template nestedTmpl = tmplObject(markup, tmplOptions); nestedTmpl.tmplName = tmplName + "/" + tagName; // Compile to AST and then to compiled function nestedTmpl.useViews = nestedTmpl.useViews || useViews; buildCode(content, nestedTmpl); useViews = nestedTmpl.useViews; nestedTmpls.push(nestedTmpl); } if (!isElse) { // This is not an else tag. tagAndElses = tagName; useViews = useViews || tagName && (!$tags[tagName] || !$tags[tagName].flow); // Switch to a new code string for this bound tag (and its elses, if it has any) - for returning the tagCtxs array oldCode = code; code = ""; } nextIsElse = ast[i + 1]; nextIsElse = nextIsElse && nextIsElse[0] === "else"; } tagStart = onError ? ";\ntry{\nret+=" : "\n+"; boundOnErrStart = ""; boundOnErrEnd = ""; if (isGetVal && (pathBindings || trigger || converter && converter !== HTML)) { // For convertVal we need a compiled function to return the new tagCtx(s) tagCtxFn = "return {" + tagCtx + "};"; tagRender = 'c("' + converter + '",view,'; tagCtxFn = new Function("data,view,j,u", " // " + tmplName + " " + tmplBindingKey + " " + tagName + "\n" + tagCtxFn); tagCtxFn._er = onError; boundOnErrStart = tagRender + tmplBindingKey + ","; boundOnErrEnd = ")"; tagCtxFn._tag = tagName; if (isLinkExpr) { return tagCtxFn; } setPaths(tagCtxFn, pathBindings); useCnvt = true; } code += (isGetVal ? (isLinkExpr ? (onError ? "\ntry{\n" : "") + "return " : tagStart) + (useCnvt // Call _cnvt if there is a converter: {{cnvt: ... }} or {^{cnvt: ... }} ? (useCnvt = undefined, useViews = hasCnvt = true, tagRender + (pathBindings ? ((tmplBindings[tmplBindingKey - 1] = tagCtxFn), tmplBindingKey) // Store the compiled tagCtxFn in tmpl.bnds, and pass the key to convertVal() : "{" + tagCtx + "}") + ")") : tagName === ">" ? (hasEncoder = true, "h(" + params[0] + ')') : (getsVal = true, "((v=" + (params[0] || 'data') + ')!=null?v:"")') // Strict equality just for data-link="title{:expr}" so expr=null will remove title attribute ) : (hasTag = true, "\n{view:view,tmpl:" // Add this tagCtx to the compiled code for the tagCtxs to be passed to renderTag() + (content ? nestedTmpls.length : "0") + "," // For block tags, pass in the key (nestedTmpls.length) to the nested content template + tagCtx + "},")); if (tagAndElses && !nextIsElse) { // This is a data-link expression or an inline tag without any elses, or the last {{else}} of an inline tag // We complete the code for returning the tagCtxs array code = "[" + code.slice(0, -1) + "]"; tagRender = 't("' + tagAndElses + '",view,this,'; if (isLinkExpr || pathBindings) { // This is a bound tag (data-link expression or inline bound tag {^{tag ...}}) so we store a compiled tagCtxs function in tmp.bnds code = new Function("data,view,j,u", " // " + tmplName + " " + tmplBindingKey + " " + tagAndElses + "\nreturn " + code + ";"); code._er = onError; code._tag = tagAndElses; if (pathBindings) { setPaths(tmplBindings[tmplBindingKey - 1] = code, pathBindings); } if (isLinkExpr) { return code; // For a data-link expression we return the compiled tagCtxs function } boundOnErrStart = tagRender + tmplBindingKey + ",undefined,"; boundOnErrEnd = ")"; } // This is the last {{else}} for an inline tag. // For a bound tag, pass the tagCtxs fn lookup key to renderTag. // For an unbound tag, include the code directly for evaluating tagCtxs array code = oldCode + tagStart + tagRender + (tmplBindingKey || code) + ")"; pathBindings = 0; tagAndElses = 0; } if (onError) { useViews = true; code += ';\n}catch(e){ret' + (isLinkExpr ? "urn " : "+=") + boundOnErrStart + 'j._err(e,view,' + onError + ')' + boundOnErrEnd + ';}\n' + (isLinkExpr ? "" : 'ret=ret'); } } } } // Include only the var references that are needed in the code code = "// " + tmplName + "\nvar v" + (hasTag ? ",t=j._tag" : "") // has tag + (hasCnvt ? ",c=j._cnvt" : "") // converter + (hasEncoder ? ",h=j.converters.html" : "") // html converter + (isLinkExpr ? ";\n" : ',ret=""\n') + (tmplOptions.debug ? "debugger;" : "") + code + (isLinkExpr ? "\n" : ";\nreturn ret;"); if ($viewsSettings._dbgMode) { code = "try {\n" + code + "\n}catch(e){\nreturn j._err(e, view);\n}"; } try { code = new Function("data,view,j,u", code); } catch (e) { syntaxError("Compiled template code:\n\n" + code + '\n: "' + e.message + '"'); } if (tmpl) { tmpl.fn = code; tmpl.useViews = !!useViews; } return code; } //========== // Utilities //========== // Merge objects, in particular contexts which inherit from parent contexts function extendCtx(context, parentContext) { // Return copy of parentContext, unless context is defined and is different, in which case return a new merged context // If neither context nor parentContext are defined, return undefined return context && context !== parentContext ? (parentContext ? $extend($extend({}, parentContext), context) : context) : parentContext && $extend({}, parentContext); } // Get character entity for HTML and Attribute encoding function getCharEntity(ch) { return charEntities[ch] || (charEntities[ch] = "&#" + ch.charCodeAt(0) + ";"); } function getTargetProps(source) { // this pointer is theMap - which has tagCtx.props too // arguments: tagCtx.args. var key, prop, props = []; if (typeof source === OBJECT) { for (key in source) { prop = source[key]; if (!prop || !prop.toJSON || prop.toJSON()) { if (!$isFunction(prop)) { props.push({ key: key, prop: prop }); } } } } return props; } function $fnRender(data, context, noIteration) { var tmplElem = this.jquery && (this[0] || error('Unknown template: "' + this.selector + '"')), tmpl = tmplElem.getAttribute(tmplAttr); return renderContent.call(tmpl ? $.data(tmplElem)[jsvTmpl] : $templates(tmplElem), data, context, noIteration); } //========================== Register converters ========================== function htmlEncode(text) { // HTML encode: Replace < > & ' and " by corresponding entities. return text != undefined ? rIsHtml.test(text) && ("" + text).replace(rHtmlEncode, getCharEntity) || text : ""; } //========================== Initialize ========================== if (!(jsr || $ && $.render)) { // JsRender not already loaded, or loaded without jQuery, and we are now moving from jsrender namespace to jQuery namepace for (jsvStoreName in jsvStores) { registerStore(jsvStoreName, jsvStores[jsvStoreName]); } $templates = $views.templates; $converters = $views.converters; $helpers = $views.helpers; $tags = $views.tags; $sub = $views.sub; $viewsSettings = $views.settings; $sub._tg.prototype = { baseApply: baseApply, cvtArgs: convertArgs }; topView = $sub.topView = new View(); //BROWSER-SPECIFIC CODE if ($) { //////////////////////////////////////////////////////////////////////////////////////////////// // jQuery (= $) is loaded $.fn.render = $fnRender; if ($.observable) { $extend($sub, $.views.sub); // jquery.observable.js was loaded before jsrender.js $views.map = $.views.map; } } else { //////////////////////////////////////////////////////////////////////////////////////////////// // jQuery is not loaded. $ = {}; if (setGlobals) { global.jsrender = $; // We are loading jsrender.js from a script element, not AMD or CommonJS, so set global } // Error warning if jsrender.js is used as template engine on Node.js (e.g. Express or Hapi...) // Use jsrender-node.js instead... $.renderFile = $.__express = $.compile = function() { throw "Node.js: use npm jsrender, or jsrender-node.js"; }; //END BROWSER-SPECIFIC CODE $.isFunction = function(ob) { return typeof ob === "function"; }; $.isArray = Array.isArray || function(obj) { return ({}.toString).call(obj) === "[object Array]"; }; $sub._jq = function(jq) { // private method to move from JsRender APIs from jsrender namespace to jQuery namespace if (jq !== $) { $extend(jq, $); // map over from jsrender namespace to jQuery namespace $ = jq; $.fn.render = $fnRender; delete $.jsrender; } }; $.jsrender = versionNumber; } $isFunction = $.isFunction; $isArray = $.isArray; $.render = $render; $.views = $views; $.templates = $templates = $views.templates; $viewsSettings({ debugMode: dbgMode, delimiters: $viewsDelimiters, onError: function(e, view, fallback) { // Can override using $.views.settings({onError: function(...) {...}}); if (view) { // For render errors, e is an exception thrown in compiled template, and view is the current view. For other errors, e is an error string. e = fallback === undefined ? "{Error: " + (e.message || e) + "}" : $isFunction(fallback) ? fallback(e, view) : fallback; } return e == undefined ? "" : e; }, _dbgMode: false }); //========================== Register tags ========================== $tags({ "if": { render: function(val) { // This function is called once for {{if}} and once for each {{else}}. // We will use the tag.rendering object for carrying rendering state across the calls. // If not done (a previous block has not been rendered), look at expression for this block and render the block if expression is truthy // Otherwise return "" var self = this, tagCtx = self.tagCtx, ret = (self.rendering.done || !val && (arguments.length || !tagCtx.index)) ? "" : (self.rendering.done = true, self.selected = tagCtx.index, // Test is satisfied, so render content on current context. We call tagCtx.render() rather than return undefined // (which would also render the tmpl/content on the current context but would iterate if it is an array) tagCtx.render(tagCtx.view, true)); // no arg, so renders against parentView.data return ret; }, flow: true }, "for": { render: function(val) { // This function is called once for {{for}} and once for each {{else}}. // We will use the tag.rendering object for carrying rendering state across the calls. var finalElse = !arguments.length, value, self = this, tagCtx = self.tagCtx, result = "", done = 0; if (!self.rendering.done) { value = finalElse ? tagCtx.view.data : val; // For the final else, defaults to current data without iteration. if (value !== undefined ) { result += tagCtx.render(value, finalElse); // Iterates except on final else, if data is an array. (Use {{include}} to compose templates without array iteration) done += $isArray(value) ? value.length : 1; } if (self.rendering.done = done) { self.selected = tagCtx.index; } // If nothing was rendered we will look at the next {{else}}. Otherwise, we are done. } return result; }, flow: true }, props: { baseTag: "for", dataMap: dataMap(getTargetProps), flow: true }, include: { flow: true }, "*": { // {{* code... }} - Ignored if template.allowCode and $.views.settings.allowCode are false. Otherwise include code in compiled template render: retVal, flow: true }, ":*": { // {{:* returnedExpression }} - Ignored if template.allowCode and $.views.settings.allowCode are false. Otherwise include code in compiled template render: retVal, flow: true }, dbg: $helpers.dbg = $converters.dbg = dbgBreak // Register {{dbg/}}, {{dbg:...}} and ~dbg() to throw and catch, as breakpoints for debugging. }); $converters({ html: htmlEncode, attr: htmlEncode, // Includes > encoding since rConvertMarkers in JsViews does not skip > characters in attribute strings url: function(text) { // URL encoding helper. return text != undefined ? encodeURI("" + text) : text === null ? text : ""; // null returns null, e.g. to remove attribute. undefined returns "" } }); //========================== Define default delimiters ========================== $viewsDelimiters(); } if (jsrToJq) { // Moving from jsrender namespace to jQuery namepace - copy over the stored items (templates, converters, helpers...) jsr.views.sub._jq($); } return $ || jsr; })); "
461
+ ],
462
+ sourceRoot: "/source/"
463
+ }