Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Crox ,是一种可以翻译成多种语言的模板
一个典型的 Crox 模板:
你好 {{root.name}}
你刚赢了 ¥{{ root.value}}
{{#if root.in_ca}}
嗯,税后 ¥{{ root.taxed_value}}
{{/if}}
提供以下数据:
{
"name": "Chris",
"value": 10000,
"taxed_value": 10000 - (10000 * 0.4),
"in_ca": true
}
将产生以下结果:
你好 Chris
你刚赢了 ¥10000
嗯,税后 ¥6000
完整写出如下(用法):
var f = crox_js(strTmpl);
var strResult = f(data);
该模板可用于前后端,可以翻译成多种语言。该模板选用了一种中间语法,可以生成一个高效的函数。该函数接受一个参数 root(以前叫 data,任意 JSON 类型的数据)。
模板,支持以下语法:
{{root}} 输出 data
{{root.name}} 输出 data.name
{{root.value * 2}} 输出 2 倍的 data.value
还支持多种运算符:. [] ! * / % + - < > <= >= === !==
{{#if root.ok}} 好,又赢了 {{/if}}
{{#if root.length > 0}} 有 {{else}} 没了 {{/if}}
{{#each root 'val'}}{{val}}{{/each}}
{{#each root 'key' 'val'}}{{key}}=>{{val}}{{/each}}
{{set a = data.lilei.mother.phone.brand}}
文件介绍
总体演示:test.htm (一个图书列表的例子)
详细的每个语法的例子汇总:examples.htm
build.wsf:打包工具,从 src 读取文件,经合并压缩,产生到 build 目录下
config.js:包含一些配置项,例如:google closure compiler 路径 和 php 路径
test.hta:js和php的集成测试(win)
crox_spec.pdf: 语法文档
如何运行 test.hta?
首先需要在 windows 下
需要 php,可以从 http://php.net/downloads.php 下载,安装到 E:\php\ 下(因为程序需要 E:\php\php.exe。可更改)
双击 test.hta,点击相应的按钮,就可以开始了(会产生一个临时文件 temp.php 在当前目录,可以自己删掉)
如何运行 build.wsf?
首先,需要在 windows 系统下
从 http://code.google.com/p/closure-compiler/ 下载,解压到 D:\gcc\ 下(因为程序需要 D:\gcc\compiler.jar,可更改)
双击 build.wsf 就可以产生 crox.js、crox_min.js 到 build 目录
有问题,建议? 欢迎直接联系我或者发 issue。谢谢!
FAQs
Crox is a high performance cross-language template engine, written by the JavaScript.
The npm package crox receives a total of 12 weekly downloads. As such, crox popularity was classified as not popular.
We found that crox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.