/* * Copyright (c) 2009-2014, Architector Inc., Japan * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // at.pkgs.js version: 1.0.0 (at=this.at||{}).pkgs=new (function(_root_){this.hash=(function(_namespace_){var table; table=[0,133,143,10,155,30,20,145,179,54,60,185,40,173,167,34,227,102,108,233,120,253,247,114,80,213,223,90,203,78,68,193,67,198,204,73,216,93,87,210,240,117,127,250,107,238,228,97,160,37,47,170,59,190,180,49,19,150,156,25,136,13,7,130,134,3,9,140,29,152,146,23,53,176,186,63,174,43,33,164,101,224,234,111,254,123,113,244,214,83,89,220,77,200,194,71,197,64,74,207,94,219,209,84,118,243,249,124,237,104,98,231,38,163,169,44,189,56,50,183,149,16,26,159,14,139,129,4,137,12,6,131,18,151,157,24,58,191,181,48,161,36,46,171,106,239,229,96,241,116,126,251,217,92,86,211,66,199,205,72,202,79,69,192,81,212,222,91,121,252,246,115,226,103,109,232,41,172,166,35,178,55,61,184,154,31,21,144,1,132,142,11,15,138,128,5,148,17,27,158,188,57,51,182,39,162,168,45,236,105,99,230,119,242,248,125,95,218,208,85,196,65,75,206,76,201,195,70,215,82,88,221,255,122,112,245,100,225,235,110,175,42,32,165,52,177,187,62,28,153,147,22,135,2,8,141]; return function(source){var index; var value; value=0; for(index=0; index0){return }binder=this.binder; this.binder=null; binder.fire(this.succeed) }}); return _class_ })(this); this.escape=new (function(){this.empty=(function(_namespace_){var _function_; _function_=function(source){return(source===null||source===void 0)?"":source.toString() }; return _function_ })(this); this.html=(function(_namespace_){var _function_; _function_=function(source){return _namespace_.empty(source).replace(/[&<>"']/g,function(matched){switch(matched){case"&":return"&"; case"<":return"<"; case">":return">"; case'"':return"""; case"'":return"'" }}) }; return _function_ })(this) })(); this.Template=(function(_namespace_){var _class_; _class_=_namespace_.Object.extend((function(source,engine,instance){instance=instance||this; this.parent.self(instance); instance.engine=engine; instance.texts=new Array(); instance.prepare(source) }),{engine:null,texts:null,code:null,prepare:function(source){var self; var codes; var last; self=this; codes=new Array(); if(source===null||source===void 0||!source.replace){throw new Error("invalid template source") }last=0; source.replace(this.engine.pattern,function(matched,code,code_,escape,escape_,raw,raw_,offset){var expression; if(last!=offset){codes.push("_text_ += _this_.text("+self.texts.length+");"); self.texts.push(source.slice(last,offset)) }last=offset+matched.length; expression=code||escape||raw; if(code){codes.push(expression) }if(escape){codes.push("_text_ += _this_.escape("+expression+");") }if(raw){codes.push("_text_ += _this_.raw("+expression+");") }if(code_||escape_||raw_){if(source.charAt(last)=="\r"){last++ }if(source.charAt(last)=="\n"){last++ }}return matched }); this.code=codes.join("\n") },text:function(index){return this.texts[index] },escape:function(source){return this.engine.escape(source) },raw:function(source){return this.engine.raw(source) },render:function(_attributes_){_attributes_=_attributes_||{}; _attributes_._this_=this; _attributes_._text_=""; with(_attributes_){eval(_this_.code) }return _attributes_._text_ }}); return _class_ })(this); this.TemplateEngine=(function(_namespace_){var _class_; _class_=_namespace_.Object.extend((function(instance){instance=instance||this; this.parent.self(instance) }),{pattern:/\{%([\s\S]*?)(%?)%\}|\{=([\s\S]*?)(=?)=\}|\{@([\s\S]*?)(@?)@\}|$/g,escape:_namespace_.escape.html,raw:_namespace_.escape.empty,prepare:function(source){var template; var renderer; template=new _namespace_.Template(source,this); renderer=function(data){return template.render(data) }; renderer.template=template; return renderer }}); _class_.instance=new _class_(); return _class_ })(this); this.template=(function(_namespace_){var _function_; _function_=function(source){return _namespace_.TemplateEngine.instance.prepare(source) }; return _function_ })(this) })(this);