{"id":19218618,"url":"https://github.com/shepherdwind/jear","last_synced_at":"2025-07-27T01:07:04.074Z","repository":{"id":10001904,"uuid":"12036031","full_name":"shepherdwind/jear","owner":"shepherdwind","description":"jsonify for velocityjs","archived":false,"fork":false,"pushed_at":"2013-08-31T09:10:08.000Z","size":100,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T00:06:21.818Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shepherdwind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-11T13:06:27.000Z","updated_at":"2013-12-10T04:19:37.000Z","dependencies_parsed_at":"2022-09-15T19:01:59.078Z","dependency_job_id":null,"html_url":"https://github.com/shepherdwind/jear","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepherdwind%2Fjear","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepherdwind%2Fjear/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepherdwind%2Fjear/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepherdwind%2Fjear/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shepherdwind","download_url":"https://codeload.github.com/shepherdwind/jear/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843975,"owners_count":21972987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T14:27:28.231Z","updated_at":"2025-05-13T00:21:10.126Z","avatar_url":"https://github.com/shepherdwind.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jear\n\njsonify for velocity\n\n## 基本原理与过程\n\n基本原理，从一个vm文件a.vm中，依次读取所有变量，生成一个结构化的a.mock.vm，在a.vm\n底部，引用a.mock.vm\n\n```\n\u003c!--\n#parse('path/to/a.mock.vm')\n--\u003e\n```\n\n通过开发的服务器，可以在html注释中得到一些准备好的数据，如下形式\n\n```\n\u003c!--\n@@@review\n{\n  \"@@!reasonFlag\": \"{{{false}}}\",\n  \"@@!caseId\": \"{{{4001308230000001}}}\",\n  \"@@tbToken.getAjaxUniqueToken()\": \"{{{5bb5de1e764ee}}}\",\n  \"@@!{myserviceModule.setTarget(==json/createMessage.vm==)}\": \"{{{http://support.daily.taobao.net/myservice/json/create_message.htm}}}\"\n}@@@\n--\u003e\n```\n\n通过执行`jear -p xx.html`可以得到json结构的数据，这些构成本地demo的模拟数据:\n\n```json\n{\n  \"$!reasonFlag\": false,\n  \"$!caseId\": \"4001308230000001\",\n  \"$tbToken.getAjaxUniqueToken()\": \"5bb5de1e764ee\",\n  \"$!{myserviceModule.setTarget(\\\"json/createMessage.vm\\\")}\": \"http://support.daily.taobao.net/myservice/json/create_message.htm\"\n}\n```\n\n这种方案，不考虑vm模板变量运算过程，只关注vm执行过程的输入和输出。\n\n- 输入: 指一个vm变量的表示形式，对于$a.b，输入即字符串'$a.b'\n- 输出: 开发通过java元算得到的结果\n\n正常情况下，变量读取是从对象查找过程，velocityjs在查找变量之前，首先对比jear提供\n的map，如果变量所对应的字符串存在于map中，直接返回结果。\n\n问题解决描述为，我们知道$a.b.c()的结果，在本地模拟过程，我们不需要知道$a对应的变\n量，我们最终只需要知道$a.b.c()的结果。开发vm中的所有变量求值过程，可以看做一堆\n函数运算，我们知道函数描述和函数的输出，但函数运算过程有无数种可能，这个过程是\n无法模拟，但是模拟运算过程，也是为了得到最终的结果。\n\n## Started\n\nInstall the module with: `npm install jear`\n\n```sh\n  Usage: jear [option] \u003cfile.vm\u003e\n\n  Options:\n\n    -h, --help               output usage information\n    -V, --version            output the version number\n    -o, --output \u003cfilename\u003e  out put filename\n    -p, --parseJSON          parse html, get json data\n\n  Examples:\n\n    $ jear xx.vm\n    $ jear -p xx.html\n    $ #pase xx.html to a.json\n    $ jear -p -o a.json xx.html\n\n```\n## License\nCopyright (c) 2013 shepherdwind  \nLicensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshepherdwind%2Fjear","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshepherdwind%2Fjear","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshepherdwind%2Fjear/lists"}