diff --git a/dist/plate.min.js b/dist/plate.min.js deleted file mode 100644 index 6abc35e..0000000 --- a/dist/plate.min.js +++ /dev/null @@ -1,3 +0,0 @@ -(function(e){if("function"==typeof bootstrap)bootstrap("plate",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makePlate=e}else"undefined"!=typeof window?window.plate=e():global.plate=e()})(function(){var define,ses,bootstrap,module,exports;return function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s11)return"p.m.";return"a.m."};proto.A=function(){if(this.data.getHours()>11)return"PM";return"AM"};proto.f=function(){if(this.data.getMinutes()==0)return this.g();return this.g()+":"+this.i()};proto.g=function(){var h=this.data.getHours();return this.data.getHours()%12||12};proto.G=function(){return this.data.getHours()};proto.h=function(){return("0"+this.g()).slice(-2)};proto.H=function(){return("0"+this.G()).slice(-2)};proto.i=function(){return("0"+this.data.getMinutes()).slice(-2)};proto.P=function(){var m=this.data.getMinutes(),h=this.data.getHours();if(m==0&&h==0)return"midnight";if(m==0&&h==12)return"noon";return this.f()+" "+this.a()};proto.s=function(){return("0"+this.data.getSeconds()).slice(-2)};proto.u=function(){return this.data.getMilliseconds()};function DateFormat(t){this.data=t;this.year_days=[0,31,59,90,120,151,181,212,243,273,304,334]}proto=DateFormat.prototype=new TimeFormat;proto.contructor=DateFormat;proto.b=function(){return MONTHS_3[this.data.getMonth()]};proto.c=function(){return this.data.toISOString?this.data.toISOString():""};proto.d=function(){return("0"+this.data.getDate()).slice(-2)};proto.D=function(){return capfirst(WEEKDAYS_ABBR[this.data.getDay()])};proto.E=function(){return MONTHS_ALT[this.data.getMonth()+1]};proto.F=function(){return capfirst(MONTHS[this.data.getMonth()])};proto.I=function(){return this.data.isDST()?"1":"0"};proto.j=function(){return this.data.getDate()};proto.l=function(){return capfirst(WEEKDAYS[this.data.getDay()])};proto.L=function(){return new Date(this.data.getFullYear(),1,29).getMonth()===1};proto.m=function(){return("0"+(this.data.getMonth()+1)).slice(-2)};proto.M=function(){return capfirst(MONTHS_3[this.data.getMonth()])};proto.n=function(){return this.data.getMonth()+1};proto.N=function(){return MONTHS_AP[this.data.getMonth()]};proto.O=function(){var tzoffs=this.data.getTimezoneOffset(),offs=~~(tzoffs/60),mins=("00"+~~Math.abs(tzoffs%60)).slice(-2);return(tzoffs>0?"-":"+")+("00"+Math.abs(offs)).slice(-2)+mins};proto.r=function(){return this.format("D, j M Y H:i:s O")};proto.S=function(){var d=this.data.getDate();if(d>=11&&d<=13)return"th";var last=d%10;if(last==1)return"st";if(last==2)return"nd";if(last==3)return"rd";return"th"};proto.t=function(){return 32-new Date(this.data.getFullYear(),this.data.getMonth(),32).getDate()};proto.T=function(){if(this.data.tzinfo){return this.data.tzinfo().abbr||"???"}return"???"};proto.U=function(){return~~(this.data/1e3)};proto.w=function(){return this.data.getDay()};proto.W=function(){var jan1_weekday=new Date(this.data.getFullYear(),0,1).getDay(),weekday=this.data.getDay(),day_of_year=this.z(),week_number,i=365;if(day_of_year<=8-jan1_weekday&&jan1_weekday>4){if(jan1_weekday===5||jan1_weekday===6&&this.L.call({data:new Date(this.data.getFullYear()-1,0,1)})){week_number=53}else{week_number=52}}else{if(this.L()){i=366}if(i-day_of_year<4-weekday){week_number=1}else{week_number=~~((day_of_year+(7-weekday)+(jan1_weekday-1))/7);if(jan1_weekday>4)week_number-=1}}return week_number};proto.y=function(){return(""+this.data.getFullYear()).slice(-2)};proto.Y=function(){return this.data.getFullYear()};proto.z=function(){doy=this.year_days[this.data.getMonth()]+this.data.getDate();if(this.L()&&this.data.getMonth()>1)doy+=1;return doy};proto.Z=function(){return this.data.getTimezoneOffset()*-60};function format(value,format_string){var df=new DateFormat(value);return df.format(format_string)}function time_format(value,format_string){var tf=new TimeFormat(value);return tf.format(format_string)}},{tz:93}],6:[function(require,module,exports){module.exports={log:function(value){console.log(value)},error:function(err){console.error(err,err&&err.stack)},info:function(value){}}},{}],7:[function(require,module,exports){var Library=require("./library");module.exports=DefaultFilters;function DefaultFilters(){Library.call(this,this.builtins)}var cons=DefaultFilters,proto=cons.prototype=new Library;proto.constructor=cons;proto.builtins={add:require("./filters/add"),addslashes:require("./filters/addslashes"),capfirst:require("./filters/capfirst"),center:require("./filters/center"),cut:require("./filters/cut"),date:require("./filters/date"),"default":require("./filters/default"),dictsort:require("./filters/dictsort"),dictsortreversed:require("./filters/dictsortreversed"),divisibleby:require("./filters/divisibleby"),escape:require("./filters/escape"),filesizeformat:require("./filters/filesizeformat"),first:require("./filters/first"),floatformat:require("./filters/floatformat"),force_escape:require("./filters/force_escape"),get_digit:require("./filters/get_digit"),index:require("./filters/index"),iteritems:require("./filters/iteritems"),iriencode:require("./filters/iriencode"),join:require("./filters/join"),last:require("./filters/last"),length:require("./filters/length"),length_is:require("./filters/length_is"),linebreaks:require("./filters/linebreaks"),linebreaksbr:require("./filters/linebreaksbr"),linenumbers:require("./filters/linenumbers"),ljust:require("./filters/ljust"),lower:require("./filters/lower"),make_list:require("./filters/make_list"),phone2numeric:require("./filters/phone2numeric"),pluralize:require("./filters/pluralize"),random:require("./filters/random"),rjust:require("./filters/rjust"),safe:require("./filters/safe"),slice:require("./filters/slice"),slugify:require("./filters/slugify"),split:require("./filters/split"),striptags:require("./filters/striptags"),timesince:require("./filters/timesince"),timeuntil:require("./filters/timeuntil"),title:require("./filters/title"),truncatechars:require("./filters/truncatechars"),truncatewords:require("./filters/truncatewords"),unordered_list:require("./filters/unordered_list"),upper:require("./filters/upper"),urlencode:require("./filters/urlencode"),urlize:require("./filters/urlize"),urlizetrunc:require("./filters/urlizetrunc"),wordcount:require("./filters/wordcount"),wordwrap:require("./filters/wordwrap"),yesno:require("./filters/yesno")}},{"./filters/add":14,"./filters/addslashes":15,"./filters/capfirst":16,"./filters/center":17,"./filters/cut":18,"./filters/date":19,"./filters/default":20,"./filters/dictsort":21,"./filters/dictsortreversed":22,"./filters/divisibleby":23,"./filters/escape":24,"./filters/filesizeformat":25,"./filters/first":26,"./filters/floatformat":27,"./filters/force_escape":28,"./filters/get_digit":29,"./filters/index":30,"./filters/iriencode":31,"./filters/iteritems":32,"./filters/join":33,"./filters/last":34,"./filters/length":35,"./filters/length_is":36,"./filters/linebreaks":37,"./filters/linebreaksbr":38,"./filters/linenumbers":39,"./filters/ljust":40,"./filters/lower":41,"./filters/make_list":42,"./filters/phone2numeric":43,"./filters/pluralize":44,"./filters/random":45,"./filters/rjust":46,"./filters/safe":47,"./filters/slice":48,"./filters/slugify":49,"./filters/split":50,"./filters/striptags":51,"./filters/timesince":52,"./filters/timeuntil":53,"./filters/title":54,"./filters/truncatechars":55,"./filters/truncatewords":56,"./filters/unordered_list":57,"./filters/upper":58,"./filters/urlencode":59,"./filters/urlize":60,"./filters/urlizetrunc":61,"./filters/wordcount":62,"./filters/wordwrap":63,"./filters/yesno":64,"./library":67}],8:[function(require,module,exports){var Library=require("./library");module.exports=DefaultTags;function DefaultTags(){Library.call(this,this.builtins)}var cons=DefaultTags,proto=cons.prototype=new Library;proto.constructor=cons;proto.builtins={block:require("./tags/block").parse,comment:require("./tags/comment").parse,debug:require("./tags/debug").parse,"extends":require("./tags/extends").parse,"for":require("./tags/for").parse,"if":require("./tags/if/node").parse,include:require("./tags/include").parse,now:require("./tags/now").parse,"with":require("./tags/with").parse}},{"./library":67,"./tags/block":73,"./tags/comment":74,"./tags/debug":75,"./tags/extends":76,"./tags/for":77,"./tags/if/node":81,"./tags/include":85,"./tags/now":86,"./tags/with":87}],9:[function(require,module,exports){module.exports=FilterApplication;var Promise=require("./promise");function FilterApplication(name,bits){this.name=name;this.args=bits;this.filter=null}var cons=FilterApplication,proto=cons.prototype;proto.attach=function(parser){this.filter=parser.filters.lookup(this.name)};proto.resolve=function(context,value,fromIDX,argValues){var self=this,promise,start=fromIDX||0,result,tmp;argValues=argValues||[];if(value===undefined){return}if(value&&value.constructor===Promise){promise=new Promise;value.once("done",function(val){promise.resolve(self.resolve(context,val))});return promise}for(var i=start,len=self.args.length;i/g,">").replace(/"/g,""").replace(/'/g,"'")}},{"./debug":6,"./promise":71}],13:[function(require,module,exports){var Token=require("./token"),FilterNode=require("./filter_node");module.exports=FilterToken;function FilterToken(content,line){Token.call(this,content,line)}var cons=FilterToken,proto=cons.prototype=new Token;proto.constructor=cons;proto.node=function(parser){return new FilterNode(parser.compile(this.content))}},{"./filter_node":12,"./token":90}],14:[function(require,module,exports){module.exports=function(input,value){return parseInt(input,10)+parseInt(value,10)}},{}],15:[function(require,module,exports){module.exports=function(input){return input.toString().replace(/'/g,"\\'")}},{}],16:[function(require,module,exports){module.exports=function(input){var str=input.toString();return[str.slice(0,1).toUpperCase(),str.slice(1)].join("")}},{}],17:[function(require,module,exports){module.exports=function(input,len,ready){if(ready===undefined)len=0;var str=input.toString(),value=" ";len-=str.length;if(len<0){return str}var len_half=len/2,arr=[],idx=Math.floor(len_half);while(idx-->0){arr.push(value)}arr=arr.join("");str=arr+str+arr;if(len_half-Math.floor(len_half)>0){str=input.toString().length%2==0?value+str:str+value}return str}},{}],18:[function(require,module,exports){module.exports=function(input,value){var str=input.toString();return str.replace(new RegExp(value,"g"),"")}},{}],19:[function(require,module,exports){var format=require("../date").date;module.exports=function(input,value,ready){if(ready===undefined)value="N j, Y";return format(input.getFullYear?input:new Date(input),value)}},{"../date":5}],20:[function(require,module,exports){module.exports=function(input,def,ready){return input?input:def}},{}],21:[function(require,module,exports){module.exports=function(input,key){return input.sort(function(x,y){if(x[key]>y[key])return 1;if(x[key]==y[key])return 0;if(x[key]=0,asNumber=parseFloat(input),absValue=Math.abs(val),pow=Math.pow(10,absValue),pow_minus_one=Math.pow(10,Math.max(absValue-1,0)),asString;asNumber=Math.round(pow*asNumber/pow_minus_one);if(val!==0)asNumber/=10;asString=asNumber.toString();if(isPositive){var split=asString.split("."),decimal=split.length>1?split[1]:"";while(decimal.length"))}return safe("

"+out.join("

")+"

")}},{"./escape":24,"./safe":47}],38:[function(require,module,exports){var escape=require("./escape"),safe=require("./safe");module.exports=function(input){var str=input.toString(),out=str.split("\n");for(var i=0,len=out.length;i"))}},{"./escape":24,"./safe":47}],39:[function(require,module,exports){module.exports=function(input){var str=input.toString(),bits=str.split("\n"),out=[],len=bits.length;while(bits.length){out.unshift(len-out.length+". "+bits.pop())}return out.join("\n")}},{}],40:[function(require,module,exports){module.exports=function(input,num){var bits=(input===null||input===undefined?"":input).toString().split(""),difference=num-bits.length;while(difference>0){difference=num-bits.push(" ")}return bits.join("")}},{}],41:[function(require,module,exports){module.exports=function(input){return input.toString().toLowerCase()}},{}],42:[function(require,module,exports){module.exports=function(input){input=input instanceof Array?input:input.toString().split("");return input}},{}],43:[function(require,module,exports){var LETTERS={a:"2",b:"2",c:"2",d:"3",e:"3",f:"3",g:"4",h:"4",i:"4",j:"5",k:"5",l:"5",m:"6",n:"6",o:"6",p:"7",q:"7",r:"7",s:"7",t:"8",u:"8",v:"8",w:"9",x:"9",y:"9",z:"9"};module.exports=function(input){var str=input.toString().toLowerCase().split(""),out=[],ltr;while(str.length){ltr=str.pop();out.unshift(LETTERS[ltr]?LETTERS[ltr]:ltr)}return out.join("")}},{}],44:[function(require,module,exports){module.exports=function(input,plural){plural=(typeof plural==="string"?plural:"s").split(",");var val=Number(input),suffix;suffix=plural[plural.length-1];if(val===1){suffix=plural.length>1?plural[0]:""}return suffix}},{}],45:[function(require,module,exports){module.exports=function(input){var cb=input.charAt||function(idx){return this[idx]};return cb.call(input,Math.floor(Math.random()*input.length))}},{}],46:[function(require,module,exports){module.exports=function(input,num){var bits=(input===null||input===undefined?"":input).toString().split(""),difference=num-bits.length;while(difference>0){difference=(bits.unshift(" "),num-bits.length)}return bits.join("")}},{}],47:[function(require,module,exports){var FilterNode=require("../filter_node");module.exports=function(input){input=new String(input);input.safe=true;return input}},{"../filter_node":12}],48:[function(require,module,exports){module.exports=function(input,by){by=by.toString();if(by.charAt(0)===":"){by="0"+by}if(by.charAt(by.length-1)===":"){by=by.slice(0,-1)}var splitBy=by.split(":"),slice=input.slice||function(){input=this.toString();return input.slice}();return slice.apply(input,splitBy)}},{}],49:[function(require,module,exports){module.exports=function(input){input=input.toString();return input.replace(/[^\w\s\d\-]/g,"").replace(/^\s*/,"").replace(/\s*$/,"").replace(/[\-\s]+/g,"-").toLowerCase()}},{}],50:[function(require,module,exports){module.exports=function(input,by,ready){by=arguments.length===2?",":by;input=""+input;return input.split(by)}},{}],51:[function(require,module,exports){module.exports=function(input){var str=input.toString();return str.replace(/<[^>]*?>/g,"")}},{}],52:[function(require,module,exports){module.exports=function(input,n,ready){var input=new Date(input),now=ready===undefined?new Date:new Date(n),diff=input-now,since=Math.abs(diff);if(diff>0)return"0 minutes";var years=~~(since/315576e5),months=~~((since-years*315576e5)/2592e6),days=~~((since-(years*315576e5+months*2592e6))/864e5),hours=~~((since-(years*315576e5+months*2592e6+days*864e5))/36e5),minutes=~~((since-(years*315576e5+months*2592e6+days*864e5+hours*36e5))/6e4),result=[years?pluralize(years,"year"):null,months?pluralize(months,"month"):null,days?pluralize(days,"day"):null,hours?pluralize(hours,"hour"):null,minutes?pluralize(minutes,"minute"):null],out=[];for(var i=0,len=result.length;i"+ulparser(item)+"");else out.unshift("
  • "+item)}return out.join("").replace(/^<\/li>/,"")+"
  • "};module.exports=function(input){return input instanceof Array?safe(ulparser(input)):input}},{"./safe":47}],58:[function(require,module,exports){module.exports=function(input){return input.toString().toUpperCase()}},{}],59:[function(require,module,exports){module.exports=function(input){return escape(input.toString())}},{}],60:[function(require,module,exports){var safe=require("./safe");var url_finder=require("../url_finder");module.exports=function(input){return safe(url_finder(input,function(){return''+arguments[0]+""}))}},{"../url_finder":91,"./safe":47}],61:[function(require,module,exports){var safe=require("./safe");var url_finder=require("../url_finder");module.exports=function(input,len){len=parseInt(len,10)||1e3;return safe(url_finder(input,function(){var ltr=arguments[0].length>len?arguments[0].slice(0,len)+"...":arguments[0];return''+ltr+""}))}},{"../url_finder":91,"./safe":47}],62:[function(require,module,exports){module.exports=function(input){var str=input.toString(),bits=str.split(/\s+/g);return bits.length}},{}],63:[function(require,module,exports){module.exports=function(input,len){var words=input.toString().split(/\s+/g),out=[],len=parseInt(len,10)||words.length;while(words.length){out.unshift(words.splice(0,len).join(" "))}return out.join("\n")}},{}],64:[function(require,module,exports){module.exports=function(input,map){var ourMap=map.toString().split(","),value;ourMap.length<3&&ourMap.push(ourMap[1]);value=ourMap[input?0:input===false?1:2];return value}},{}],65:[function(require,module,exports){(function(global){var FilterToken=require("./filter_token"),TagToken=require("./tag_token"),CommentToken=require("./comment_token"),TextToken=require("./text_token"),libraries=require("./libraries"),Parser=require("./parser"),Context=require("./context"),Meta=require("./meta"),Promise=require("./promise");module.exports=Template;Template.Template=Template;Template.Context=Context;var later=typeof global!=="undefined"?function(fn){global.setTimeout(fn,0)}:function(fn){this.setTimeout(fn,0)};function Template(raw,libraries,parser){if(typeof raw!=="string"){throw new TypeError("input should be a string")}this.raw=raw;libraries=libraries||{};this.tagLibrary=libraries.tag_library||Template.Meta.createTagLibrary();this.filterLibrary=libraries.filter_library||Template.Meta.createFilterLibrary();this.pluginLibrary=libraries.plugin_library||Template.Meta.createPluginLibrary();this.parser=parser||Parser;this.tokens=null}var cons=Template,proto=cons.prototype,meta=cons.Meta=new Meta;cons.createPluginLibrary=function(){return new libraries.DefaultPluginLibrary};proto.getNodeList=function(){this.nodelist=this.nodelist||this.parse();return this.nodelist};proto.parse=function(){var parser;this.tokens=this.tokens||cons.tokenize(this.raw);parser=new this.parser(this.tokens,this.tagLibrary,this.filterLibrary,this.pluginLibrary,this);return parser.parse()};proto.render=protect(function(context,ready){context=new Context(context);var result;result=this.getNodeList().render(context);if(result.constructor===Promise){result.once("done",function(data){ready(null,data)})}else{later(function(){ready(null,result)},0)}});function protect(fn){return function(context,ready){if(!context||!ready){throw new TypeError}try{return fn.call(this,context,ready)}catch(e){later(function(){ready(e,null)},0)}}}cons.MATCH_RE=/\{[%#\{](.*?)[\}#%]\}/;cons.tokenize=function(content){var match=null,tokens=[],lineNo=1,incLineNo=function(str){lineNo+=str.split("\n").length},map={"%":TagToken,"#":CommentToken,"{":FilterToken},rex=this.MATCH_RE,literal;do{match=rex.exec(content);if(!match)continue;literal=content.slice(0,match.index);incLineNo(literal);if(match.index)tokens.push(new TextToken(literal.slice(0,match.index,lineNo)));match[1]=match[1].replace(/^\s+/,"").replace(/\s+$/,"");tokens.push(new(map[match[0].charAt(1)])(match[1],lineNo));content=content.slice(match.index+match[0].length)}while(content.length&&match);tokens.push(new TextToken(content));return tokens}})(self)},{"./comment_token":3,"./context":4,"./filter_token":13,"./libraries":66,"./meta":68,"./parser":70,"./promise":71,"./tag_token":72,"./text_token":89}],66:[function(require,module,exports){module.exports={Library:require("./library"),DefaultPluginLibrary:require("./library"),DefaultTagLibrary:require("./defaulttags"),DefaultFilterLibrary:require("./defaultfilters")}},{"./defaultfilters":7,"./defaulttags":8,"./library":67}],67:[function(require,module,exports){module.exports=Library;var Promise=require("./promise");function Library(lib){this.registry=lib||{}}var cons=Library,proto=cons.prototype;proto.lookup=errorOnNull(function(name){var out=this.registry[name]||null;if(typeof out==="function"&&out.length===2&&name==="loader"){out=Promise.toPromise(out)}return out},"Could not find {0}!");proto.register=errorOnNull(function(name,item){if(this.registry[name])return null;this.registry[name]=item},"{0} is already registered!");function errorOnNull(fn,msg){return function(){var result=fn.call(this,arguments[0],arguments[1]),args=arguments; -if(result===null)throw new Error(msg.replace(/\{(\d+?)\}/g,function(a,m){return args[+m]}));return result}}},{"./promise":71}],68:[function(require,module,exports){var libraries=require("./libraries");module.exports=Meta;function Meta(){this._autoregister={plugin:{},tag:{},filter:{}};this._cache={};this._classes={filter:libraries.DefaultFilterLibrary,plugin:libraries.DefaultPluginLibrary,tag:libraries.DefaultTagLibrary}}var cons=Meta,proto=cons.prototype;proto.createPluginLibrary=createLibrary("plugin");proto.createFilterLibrary=createLibrary("filter");proto.createTagLibrary=createLibrary("tag");proto.registerPlugin=createAutoregister("plugin");proto.registerFilter=createAutoregister("filter");proto.registerTag=createAutoregister("tag");function createAutoregister(name){return function(key,item){if(this._cache[name])this._cache[name].register(key,item);else this._autoregister[name][key]=item}}function createLibrary(name){return function(){if(this._cache[name])return this._cache[name];var lib=new this._classes[name];for(var key in this._autoregister[name]){lib.register(key,this._autoregister[name][key])}this._cache[name]=lib;return lib}}},{"./libraries":66}],69:[function(require,module,exports){module.exports=NodeList;var Promise=require("./promise");function NodeList(nodes){this.nodes=nodes}var cons=NodeList,proto=cons.prototype;proto.render=function(context){var promises=[],results=[],nodes=this.nodes,result;for(var i=0,len=nodes.length;i0){token=this.tokens.shift();if(until&&token.is(until)&&token.constructor===TagToken){this.tokens.unshift(token);okay=true;break}if(node=token.node(this)){output.push(node)}}if(!okay){throw new Error("expected one of "+until)}return new NodeList(output)};proto.compileNumber=function(content,idx,output){var decimal=content.charAt(idx)===".",bits=decimal?["0."]:[],parse,c;do{c=content.charAt(idx);if(c==="."){if(decimal){break}decimal=true;bits.push(".")}else if(/\d/.test(c)){bits.push(c)}}while(++idx":function(){return new InfixOperator(10,function(x,y){return x>y})},">=":function(){return new InfixOperator(10,function(x,y){return x>=y})},"<":function(){return new InfixOperator(10,function(x,y){return x=this.tokens.length){return new EndToken}return this.tokens[this.pos++]};proto.parse=function(){var retval=this.expression();if(!(this.currentToken.constructor===EndToken)){throw new Error("Unused "+this.currentToken+" at end of if expression.")}return retval};proto.expression=function(rbp){rbp=rbp||0;var t=this.currentToken,left;this.currentToken=this.next();left=t.nud(this);while(rbp"};proto.is=function(names){for(var i=0,len=names.length;ithresholds.fall_back,max=Math.max(thresholds.fall_back,thresholds.spring_forward),min=Math.min(thresholds.fall_back,thresholds.spring_forward);if(min0?"-":"+")+("00"+Math.abs(offs)).slice(-2)+mins;return offs}function tzinfo(date,tz_list,determine_dst,TZ){var fmt=get_offset_fmt(date.getTimezoneOffset());TZ=TZ||tz;tz_list=tz_list||TZ[fmt];determine_dst=determine_dst||isDST;var date_is_dst=determine_dst(date),date_dst_thresholds=determine_dst.find_thresholds(),has_dst=date_dst_thresholds.spring_forward!==date_dst_thresholds.fall_back,is_north=has_dst&&date_dst_thresholds.spring_forward + {%- if figure.type == "material-icons" -%} + {#- https://material.io/icons/ -#} + {{ figure.name }} + {%- elif figure.type == "mdi" -%} + {#- https://materialdesignicons.com/ -#} + + {%- elif figure.type == "fa" -%} + {#- http://fontawesome.io/icons/ -#} + + {%- elif figure.type == "lnr" -%} + {#- https://linearicons.com/free -#} + + {%- elif figure.type == "svg" -%} + {#- /cards/svg -#} + + {%- elif figure.type == "img" -%} + {#- /cards/img -#} + + {%- endif -%} + +{%- endmacro -%} + +
    +
    {{ card.title }}
    +
    + {% for figure in card.figures -%} + {{ figure_layer(figure) }} + {% endfor %} +
    + + + {%- for cost in card.costs %} +
    + {%- if cost.split() | length == 2 and cost.split()[0].isnumeric() %} + {{ cost.split()[0] }}
    + {{ cost.split()[1] }} + {% else %} + {{ cost }} + {% endif %} +
    + {%- endfor %} +
    +
    +
    "{{ card.flavor }}"
    +
    {{ card.description | markdown | safe }}
    + + {%- if card.steps %} +
      + {% for step in card.steps -%} +
    • {{ step }}
    • + {% endfor %} +
    + {%- endif %} + +
    +
    + +{#-
    {{ card }}
    -#} diff --git a/style.js b/style.js index 6ce21dd..1e1a90e 100644 --- a/style.js +++ b/style.js @@ -1,13 +1,31 @@ +var md = window.markdownit(); +var context = { + 'card' : jsyaml.load(document.getElementById("yaml_data").innerHTML), + 'alert' : alert, +}; -var template = new plate.Template(jinja_template) -var context = jsyaml.load(document.getElementById("yaml_data").innerHTML); +var env = new nunjucks.Environment({ + autoescape: true +}); +env.addFilter('markdown', function(str) { + return md.render(str); +}); +env.addFilter('cull_whitespace', function(str) { + return str.split(/\s+/).join(' ').trim(); +}); +env.addFilter('any', function(iterable) { + for (var index = 0; index < iterable.length; index++) { + if (iterable[index]) return true; + } + return false; +}); +env.addFilter('all', function(iterable) { + for (var index = 0; index < iterable.length; index++) { + if (!iterable[index]) return false; + } + return true; +}); - - -console.log(yaml_data); - -template.render(context, function(err, data) { - if (err) throw err; - document.getElementById("my_card").innerHTML = data; -// document.write(data); -}) +rendered = env.renderString(jinja_template, context); +console.log(rendered); +document.getElementById("my_card").innerHTML = rendered; diff --git a/templates/card.xml.j2 b/templates/card.xml.j2 index 2a8a847..79cb018 100644 --- a/templates/card.xml.j2 +++ b/templates/card.xml.j2 @@ -1,3 +1,3 @@ - - {{ data }} - + +{{ data }} + diff --git a/templates/style.xsl.j2 b/templates/style.xsl.j2 index c46488e..a60d869 100644 --- a/templates/style.xsl.j2 +++ b/templates/style.xsl.j2 @@ -4,28 +4,48 @@ <!DOCTYPE html> +{% set newline = "\n" %} +{% set async = "media=\"none\" onload=\"if(media!='all')media='all'\"" %} + +{% filter replace("\n", newline) %} +{{ newline*2 }} +{{ newline*2 }} +