openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

soy.min.js (6209B)


      1 (function(e){if(typeof exports=='object'&&typeof module=='object')e(require('../../lib/codemirror'),require('../htmlmixed/htmlmixed'));else if(typeof define=='function'&&define.amd)define(['../../lib/codemirror','../htmlmixed/htmlmixed'],e);else e(CodeMirror)})(function(e){'use strict';var t=['template','literal','msg','fallbackmsg','let','if','elseif','else','switch','case','default','foreach','ifempty','for','call','param','deltemplate','delcall','log'];e.defineMode('soy',function(a){var r=e.getMode(a,'text/plain'),s={html:e.getMode(a,{name:'text/html',multilineTagIndentFactor:2,multilineTagIndentPastTag:!1}),attributes:r,text:r,uri:r,css:e.getMode(a,'text/css'),js:e.getMode(a,{name:'text/javascript',statementIndent:2*a.indentUnit})};function n(e){return e[e.length-1]};function l(e,t,s){if(e.sol()){for(var i=0;i<t.indent;i++){if(!e.eat(/\s/))break};if(i)return null};var a=e.string,r=s.exec(a.substr(e.pos));if(r){e.string=a.substr(0,e.pos+r.index)};var l=e.hideFirstChars(t.indent,function(){var a=n(t.localStates);return a.mode.token(e,a.state)});e.string=a;return l};function d(e,t){while(e){if(e.element===t)return!0;e=e.next};return!1};function i(e,t){return{element:t,next:e}};function o(e,t,a){return d(e,t)?'variable-2':(a?'variable':'variable-2 error')};function c(e){if(e.scopes){e.variables=e.scopes.element;e.scopes=e.scopes.next}};return{startState:function(){return{kind:[],kindTag:[],soyState:[],templates:null,variables:i(null,'ij'),scopes:null,indent:0,quoteKind:null,localStates:[{mode:s.html,state:e.startState(s.html)}]}},copyState:function(t){return{tag:t.tag,kind:t.kind.concat([]),kindTag:t.kindTag.concat([]),soyState:t.soyState.concat([]),templates:t.templates,variables:t.variables,scopes:t.scopes,indent:t.indent,quoteKind:t.quoteKind,localStates:t.localStates.map(function(t){return{mode:t.mode,state:e.copyState(t.mode,t.state)}})}},token:function(d,r){var u;switch(n(r.soyState)){case'comment':if(d.match(/^.*?\*\//)){r.soyState.pop()}
      2 else{d.skipToEnd()};if(!r.scopes){var h=/@param\??\s+(\S+)/g,g=d.current();for(var u;(u=h.exec(g));){r.variables=i(r.variables,u[1])}};return'comment';case'string':var u=d.match(/^.*?(["']|\\[\s\S])/);if(!u){d.skipToEnd()}
      3 else if(u[1]==r.quoteKind){r.quoteKind=null;r.soyState.pop()};return'string'};if(d.match(/^\/\*/)){r.soyState.push('comment');return'comment'}
      4 else if(d.match(d.sol()||(r.soyState.length&&n(r.soyState)!='literal')?/^\s*\/\/.*/:/^\s+\/\/.*/)){return'comment'};switch(n(r.soyState)){case'templ-def':if(u=d.match(/^\.?([\w]+(?!\.[\w]+)*)/)){r.templates=i(r.templates,u[1]);r.scopes=i(r.scopes,r.variables);r.soyState.pop();return'def'};d.next();return null;case'templ-ref':if(u=d.match(/^\.?([\w]+)/)){r.soyState.pop();if(u[0][0]=='.'){return o(r.templates,u[1],!0)};return'variable'};d.next();return null;case'param-def':if(u=d.match(/^\w+/)){r.variables=i(r.variables,u[0]);r.soyState.pop();r.soyState.push('param-type');return'def'};d.next();return null;case'param-type':if(d.peek()=='}'){r.soyState.pop();return null};if(d.eatWhile(/^[\w]+/)){return'variable-3'};d.next();return null;case'var-def':if(u=d.match(/^\$([\w]+)/)){r.variables=i(r.variables,u[1]);r.soyState.pop();return'def'};d.next();return null;case'tag':if(d.match(/^\/?}/)){if(r.tag=='/template'||r.tag=='/deltemplate'){c(r);r.variables=i(null,'ij');r.indent=0}
      5 else{if(r.tag=='/for'||r.tag=='/foreach'){c(r)};r.indent-=a.indentUnit*(d.current()=='/}'||t.indexOf(r.tag)==-1?2:1)};r.soyState.pop();return'keyword'}
      6 else if(d.match(/^([\w?]+)(?==)/)){if(d.current()=='kind'&&(u=d.match(/^="([^"]+)/,!1))){var p=u[1];r.kind.push(p);r.kindTag.push(r.tag);var f=s[p]||s.html,m=n(r.localStates);if(m.mode.indent){r.indent+=m.mode.indent(m.state,'')};r.localStates.push({mode:f,state:e.startState(f)})};return'attribute'}
      7 else if(u=d.match(/^["']/)){r.soyState.push('string');r.quoteKind=u;return'string'};if(u=d.match(/^\$([\w]+)/)){return o(r.variables,u[1])};if(u=d.match(/^\w+/)){return/^(?:as|and|or|not|in)$/.test(u[0])?'keyword':null};d.next();return null;case'literal':if(d.match(/^(?=\{\/literal})/)){r.indent-=a.indentUnit;r.soyState.pop();return this.token(d,r)};return l(d,r,/\{\/literal}/)};if(d.match(/^\{literal}/)){r.indent+=a.indentUnit;r.soyState.push('literal');return'keyword'}
      8 else if(u=d.match(/^\{([\/@\\]?\w+\??)(?=[\s\}]|\/[/*])/)){if(u[1]!='/switch')r.indent+=(/^(\/|(else|elseif|ifempty|case|fallbackmsg|default)$)/.test(u[1])&&r.tag!='switch'?1:2)*a.indentUnit;r.tag=u[1];if(r.tag=='/'+n(r.kindTag)){r.kind.pop();r.kindTag.pop();r.localStates.pop();var m=n(r.localStates);if(m.mode.indent){r.indent-=m.mode.indent(m.state,'')}};r.soyState.push('tag');if(r.tag=='template'||r.tag=='deltemplate'){r.soyState.push('templ-def')}
      9 else if(r.tag=='call'||r.tag=='delcall'){r.soyState.push('templ-ref')}
     10 else if(r.tag=='let'){r.soyState.push('var-def')}
     11 else if(r.tag=='for'||r.tag=='foreach'){r.scopes=i(r.scopes,r.variables);r.soyState.push('var-def')}
     12 else if(r.tag=='namespace'){if(!r.scopes){r.variables=i(null,'ij')}}
     13 else if(r.tag.match(/^@(?:param\??|inject)/)){r.soyState.push('param-def')};return'keyword'}
     14 else if(d.eat('{')){r.tag='print';r.indent+=2*a.indentUnit;r.soyState.push('tag');return'keyword'};return l(d,r,/\{|\s+\/\/|\/\*/)},indent:function(t,i){var s=t.indent,l=n(t.soyState);if(l=='comment')return e.Pass;if(l=='literal'){if(/^\{\/literal}/.test(i))s-=a.indentUnit}
     15 else{if(/^\s*\{\/(template|deltemplate)\b/.test(i))return 0;if(/^\{(\/|(fallbackmsg|elseif|else|ifempty)\b)/.test(i))s-=a.indentUnit;if(t.tag!='switch'&&/^\{(case|default)\b/.test(i))s-=a.indentUnit;if(/^\{\/switch\b/.test(i))s-=a.indentUnit};var r=n(t.localStates);if(s&&r.mode.indent){s+=r.mode.indent(r.state,i)};return s},innerMode:function(e){if(e.soyState.length&&n(e.soyState)!='literal')return null;else return n(e.localStates)},electricInput:/^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/,lineComment:'//',blockCommentStart:'/*',blockCommentEnd:'*/',blockCommentContinue:' * ',useInnerComments:!1,fold:'indent'}},'htmlmixed');e.registerHelper('hintWords','soy',t.concat(['delpackage','namespace','alias','print','css','debugger']));e.defineMIME('text/x-soy','soy')});