| Current Path : /home/purehotels/public_html/media/editors/codemirror/mode/soy/ |
| Current File : /home/purehotels/public_html/media/editors/codemirror/mode/soy/soy.min.js |
!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../htmlmixed/htmlmixed")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../htmlmixed/htmlmixed"],a):a(CodeMirror)})((function(a){"use strict";var b={noEndTag:!0,soyState:"param-def"},c={alias:{noEndTag:!0},delpackage:{noEndTag:!0},namespace:{noEndTag:!0,soyState:"namespace-def"},"@param":b,"@param?":b,"@inject":b,"@inject?":b,"@state":b,template:{soyState:"templ-def",variableScope:!0},literal:{},msg:{},fallbackmsg:{noEndTag:!0,reduceIndent:!0},select:{},plural:{},let:{soyState:"var-def"},if:{},elseif:{noEndTag:!0,reduceIndent:!0},else:{noEndTag:!0,reduceIndent:!0},switch:{},case:{noEndTag:!0,reduceIndent:!0},default:{noEndTag:!0,reduceIndent:!0},foreach:{variableScope:!0,soyState:"var-def"},ifempty:{noEndTag:!0,reduceIndent:!0},for:{variableScope:!0,soyState:"var-def"},call:{soyState:"templ-ref"},param:{soyState:"param-ref"},print:{noEndTag:!0},deltemplate:{soyState:"templ-def",variableScope:!0},delcall:{soyState:"templ-ref"},log:{},element:{variableScope:!0}},d=Object.keys(c).filter((function(a){return!c[a].noEndTag||c[a].reduceIndent}));a.defineMode("soy",(function(b){function e(a){return a[a.length-1]}function f(a,b,c){if(a.sol()){for(var d=0;d<b.indent&&a.eat(/\s/);d++);if(d)return null}var f=a.string,g=c.exec(f.substr(a.pos));g&&(a.string=f.substr(0,a.pos+g.index));var h=a.hideFirstChars(b.indent,(function(){var c=e(b.localStates);return c.mode.token(a,c.state)}));return a.string=f,h}function g(a,b){for(;a;){if(a.element===b)return!0;a=a.next}return!1}function h(a,b){return{element:b,next:a}}function i(a){a.context&&(a.context.scope&&(a.variables=a.context.scope),a.context=a.context.previousContext)}function j(a,b,c){return g(a,b)?"variable-2":c?"variable":"variable-2 error"}function k(a,b,c){this.previousContext=a,this.tag=b,this.kind=null,this.scope=c}function l(a,b){var c;return a.match(/[[]/)?(b.soyState.push("list-literal"),b.lookupVariables=!1,null):a.match(/map\b/)?(b.soyState.push("map-literal"),"keyword"):a.match(/record\b/)?(b.soyState.push("record-literal"),"keyword"):a.match(/([\w]+)(?=\()/)?"variable callee":(c=a.match(/^["']/))?(b.soyState.push("string"),b.quoteKind=c[0],"string"):a.match(/^[(]/)?(b.soyState.push("open-parentheses"),null):a.match(/(null|true|false)(?!\w)/)||a.match(/0x([0-9a-fA-F]{2,})/)||a.match(/-?([0-9]*[.])?[0-9]+(e[0-9]*)?/)?"atom":a.match(/(\||[+\-*\/%]|[=!]=|\?:|[<>]=?)/)?"operator":(c=a.match(/^\$([\w]+)/))?j(b.variables,c[1],!b.lookupVariables):(c=a.match(/^\w+/))?/^(?:as|and|or|not|in|if)$/.test(c[0])?"keyword":null:(a.next(),null)}var m=a.getMode(b,"text/plain"),n={html:a.getMode(b,{name:"text/html",multilineTagIndentFactor:2,multilineTagIndentPastTag:!1}),attributes:m,text:m,uri:m,trusted_resource_uri:m,css:a.getMode(b,"text/css"),js:a.getMode(b,{name:"text/javascript",statementIndent:2*b.indentUnit})};return{startState:function(){return{soyState:[],variables:h(null,"ij"),scopes:null,indent:0,quoteKind:null,context:null,lookupVariables:!0,localStates:[{mode:n.html,state:a.startState(n.html)}]}},copyState:function(b){return{tag:b.tag,soyState:b.soyState.concat([]),variables:b.variables,context:b.context,indent:b.indent,quoteKind:b.quoteKind,lookupVariables:b.lookupVariables,localStates:b.localStates.map((function(b){return{mode:b.mode,state:a.copyState(b.mode,b.state)}}))}},token:function(g,j){var m;switch(e(j.soyState)){case"comment":if(g.match(/^.*?\*\//)?j.soyState.pop():g.skipToEnd(),!j.context||!j.context.scope)for(var m,o=/@param\??\s+(\S+)/g,p=g.current();m=o.exec(p);)j.variables=h(j.variables,m[1]);return"comment";case"string":var m=g.match(/^.*?(["']|\\[\s\S])/);return m?m[1]==j.quoteKind&&(j.quoteKind=null,j.soyState.pop()):g.skipToEnd(),"string"}if(!j.soyState.length||"literal"!=e(j.soyState)){if(g.match(/^\/\*/))return j.soyState.push("comment"),"comment";if(g.match(g.sol()?/^\s*\/\/.*/:/^\s+\/\/.*/))return"comment"}switch(e(j.soyState)){case"templ-def":return(m=g.match(/^\.?([\w]+(?!\.[\w]+)*)/))?(j.soyState.pop(),"def"):(g.next(),null);case"templ-ref":return(m=g.match(/(\.?[a-zA-Z_][a-zA-Z_0-9]+)+/))?(j.soyState.pop(),"."==m[0][0]?"variable-2":"variable"):(g.next(),null);case"namespace-def":return(m=g.match(/^\.?([\w\.]+)/))?(j.soyState.pop(),"variable"):(g.next(),null);case"param-def":return(m=g.match(/^\w+/))?(j.variables=h(j.variables,m[0]),j.soyState.pop(),j.soyState.push("param-type"),"def"):(g.next(),null);case"param-ref":return(m=g.match(/^\w+/))?(j.soyState.pop(),"property"):(g.next(),null);case"open-parentheses":return g.match(/[)]/)?(j.soyState.pop(),null):l(g,j);case"param-type":var q=g.peek();return-1!="}]=>,".indexOf(q)?(j.soyState.pop(),null):"["==q?(j.soyState.push("param-type-record"),null):(m=g.match(/^([\w]+|[?])/))?("map"!=m[0]&&"list"!=m[0]||j.soyState.push("param-type-map-list"),"type"):(g.next(),null);case"param-type-record":var q=g.peek();return"]"==q?(j.soyState.pop(),null):g.match(/^\w+/)?(j.soyState.push("param-type"),"property"):(g.next(),null);case"param-type-map-list":var q=g.peek();return g.match(/^[>]/)?(j.soyState.pop(),null):g.match(/^[<,]/)?(j.soyState.push("param-type"),null):(g.next(),null);case"var-def":return(m=g.match(/^\$([\w]+)/))?(j.variables=h(j.variables,m[1]),j.soyState.pop(),"def"):(g.next(),null);case"record-literal":return g.match(/^[)]/)?(j.soyState.pop(),null):g.match(/[(,]/)?(j.soyState.push("map-value"),j.soyState.push("record-key"),null):(g.next(),null);case"map-literal":return g.match(/^[)]/)?(j.soyState.pop(),null):g.match(/[(,]/)?(j.soyState.push("map-value"),j.soyState.push("map-value"),null):(g.next(),null);case"list-literal":return g.match(/\]/)?(j.soyState.pop(),j.lookupVariables=!0,null):g.match(/for\b/)?(j.soyState.push("var-def"),"keyword"):g.match(/in\b/)?(j.lookupVariables=!0,"keyword"):l(g,j);case"record-key":return g.match(/[\w]+/)?"property":g.match(/^[:]/)?(j.soyState.pop(),null):(g.next(),null);case"map-value":return")"==g.peek()||","==g.peek()||g.match(/^[:)]/)?(j.soyState.pop(),null):l(g,j);case"tag":var r="/"==j.tag[0],s=r?j.tag.substring(1):j.tag,t=c[s];if(g.match(/^\/?}/)){var u="/}"==g.current();return u&&!r&&i(j),"/template"==j.tag||"/deltemplate"==j.tag?(j.variables=h(null,"ij"),j.indent=0):j.indent-=b.indentUnit*(u||-1==d.indexOf(j.tag)?2:1),j.soyState.pop(),"keyword"}if(g.match(/^([\w?]+)(?==)/)){if(j.context&&j.context.tag==s&&"kind"==g.current()&&(m=g.match(/^="([^"]+)/,!1))){var v=m[1];j.context.kind=v;var w=n[v]||n.html,x=e(j.localStates);x.mode.indent&&(j.indent+=x.mode.indent(x.state,"","")),j.localStates.push({mode:w,state:a.startState(w)})}return"attribute"}return l(g,j);case"literal":return g.match(/^(?=\{\/literal})/)?(j.soyState.pop(),this.token(g,j)):f(g,j,/\{\/literal}/)}if(g.match(/^\{literal}/))return j.indent+=b.indentUnit,j.soyState.push("literal"),j.context=new k(j.context,"literal",j.variables),"keyword";if(m=g.match(/^\{([/@\\]?\w+\??)(?=$|[\s}]|\/[/*])/)){var y=j.tag;j.tag=m[1];var r="/"==j.tag[0],z=!!c[j.tag],s=r?j.tag.substring(1):j.tag,t=c[s];"/switch"!=j.tag&&(j.indent+=((r||t&&t.reduceIndent)&&"switch"!=y?1:2)*b.indentUnit),j.soyState.push("tag");var A=!1;if(t)if(r||t.soyState&&j.soyState.push(t.soyState),t.noEndTag||!z&&r){if(r)if(j.context&&j.context.tag==s){if(j.context){if(j.context.kind){j.localStates.pop();var x=e(j.localStates);x.mode.indent&&(j.indent-=x.mode.indent(x.state,"",""))}i(j)}}else A=!0}else j.context=new k(j.context,j.tag,t.variableScope?j.variables:null);else r&&(A=!0);return(A?"error ":"")+"keyword"}return g.eat("{")?(j.tag="print",j.indent+=2*b.indentUnit,j.soyState.push("tag"),"keyword"):f(g,j,/\{|\s+\/\/|\/\*/)},indent:function(c,d,f){var g=c.indent,h=e(c.soyState);if("comment"==h)return a.Pass;if("literal"==h)/^\{\/literal}/.test(d)&&(g-=b.indentUnit);else{if(/^\s*\{\/(template|deltemplate)\b/.test(d))return 0;/^\{(\/|(fallbackmsg|elseif|else|ifempty)\b)/.test(d)&&(g-=b.indentUnit),"switch"!=c.tag&&/^\{(case|default)\b/.test(d)&&(g-=b.indentUnit),/^\{\/switch\b/.test(d)&&(g-=b.indentUnit)}var i=e(c.localStates);return g&&i.mode.indent&&(g+=i.mode.indent(i.state,d,f)),g},innerMode:function(a){return a.soyState.length&&"literal"!=e(a.soyState)?null:e(a.localStates)},electricInput:/^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/,lineComment:"//",blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * ",useInnerComments:!1,fold:"indent"}}),"htmlmixed"),a.registerHelper("wordChars","soy",/[\w$]/),a.registerHelper("hintWords","soy",Object.keys(c).concat(["css","debugger"])),a.defineMIME("text/x-soy","soy")}));