一种简单但功能强大的文本插值模板语言,灵感来自SAS宏。
sassylang的Python项目详细描述
时髦
一种简单但功能强大的文本插值模板语言,灵感来自SAS宏。
工作原理
sassy是一个解释输入宏标记的命令行程序。
宏
%let var1 = some value; %let var2 = some other value; %macro testMacro(param1); this text will show whenever the macro is called. variables can be referenced like this: &var1. we can reference macro parameters just like variables: ¶m1. %mend; here's how you call a macro: %exec testMacro(1); here's a call to the same macro with a different parameter: %exec testMacro(2);
在上述文本文件上运行sassy将输出以下内容…
$ sassy test.txt here's how you call a macro: this text will show whenever the macro is called. variables can be referenced like this: somevalue we can reference macro parameters just like variables: 1 here's a call to the same macro with a different parameter: this text will show whenever the macro is called. variables can be referenced like this: somevalue we can reference macro parameters just like variables: 2
嵌套变量解析
%let var1 = some value; %let var2 = some other value; %let varNum = 1; %macro testMacro(param1); variables can be nested to form references to other variables: &var&varNum.. ...and also nest parameters as with variables: &var¶m1.. %mend; here's how you call a macro: %exec testMacro(1); here's a call to the same macro with a different parameter: %exec testMacro(2);
在上述文本文件上运行sassy将输出以下内容…
$ sassy test.txt here's how you call a macro: variables can be nested to form references to other variables: somevalue ...and also nest parameters as with variables: somevalue here's a call to the same macro with a different parameter: variables can be nested to form references to other variables: somevalue ...and also nest parameters as with variables: someothervalue
循环
this is how you execute a loop: %procloop (3) loopCounter; this loop will execute &loopCounter. times. %pend; ...you can also use a variable to set the number of iterations: %let loopVar0 = first loop; %let loopVar1 = second loop; %let loopVar2 = third loop; %let loopVar3 = fourth loop; %let numLoops = 4; %procloop (&numLoops.) counterVar; this other loop will execute &counterVar. times, and references a different variable each time: &loopVar&counterVar.. %pend;
在上述文本文件上运行sassy将输出以下内容…
$ sassy test.txt this is how you execute a loop: this loop will execute 0 times. this loop will execute 1 times. this loop will execute 2 times. ...you can also use a variable to set the number of iterations: this other loop will execute 0 times, and references a different variable each time: firstloop this other loop will execute 1 times, and references a different variable each time: secondloop this other loop will execute 2 times, and references a different variable each time: thirdloop this other loop will execute 3 times, and references a different variable each time: fourthloop
安装
以下是安装Sassy所需的操作:
Python3.6
sassy与python 3.6及更高版本兼容。
在unix系统上,通过包管理器(apt、rpm、yum、brew)安装python 3.6(或更高版本)。 或者,可以从official Python downloads page下载安装包。
虚拟环境
建议将所有项目依赖项放入其自己的虚拟 环境-这样我们就不会污染全局python安装。 为此,我们建议您使用virtualenvwrapper。按照说明操作 here 来安装这个。安装virtualenvwrapper后,创建 一个新的虚拟环境:
mkvirtualenv sassy workon sassy
现在让我们安装sassy:
pip install sassylang
获得帮助或给予帮助
- 打开一个新的 issue如果 你遇到了一个问题。
- 欢迎拉取请求。你可以帮助语言功能!
许可证
- Sassy是免费软件,并根据 GPLv3。
- 主要作者是@jmsmistral