Created
March 6, 2012 04:48
-
-
Save cognitom/1983635 to your computer and use it in GitHub Desktop.
YinYangのテンプレートタグ用正規表現 for codeReview.cafe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| re = | |
| pend: /<!--\{end\}-->/ | |
| more: /<!--\{more\}-->/ | |
| pvar: /<!--\{(@[a-zA-Z0-9_\.\#>=\[\]]+|[a-zA-Z][a-zA-Z0-9_\.]*)(\|.*?)*\}-->/ | |
| ivar: /\#\{(@[a-zA-Z0-9_\.\#>=\[\]]+|[a-zA-Z][a-zA-Z0-9_\.]*)(\|.*?)*\}/ | |
| loop: /<!--\{[a-zA-Z][a-zA-Z0-9_\.]* in (@[a-zA-Z0-9_\.\#>=\[\]]+|[a-zA-Z][a-zA-Z0-9_\.]*)\}-->/ | |
| if value.match re.pend then @ignore = false; @parent | |
| else if value.match re.more then @ignore = true; @ | |
| else unless @ignore | |
| if value.match re.pvar then @_add 'child', new TemplateVar @, value.replace(/<!--{|}-->/g, ''), true | |
| else if value.match re.ivar then @_add 'self', new TemplateVar @, value.replace /\#\{|\}/g, '' | |
| else if value.match re.loop then @_add 'child', new TemplateLoop @, value.replace /<!--{|}-->/g, '' | |
| else @_add 'self', new TemplateText @, value | |
| else @ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment