一种简单但功能强大的文本插值模板语言,灵感来自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: &param1.
%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&param1..
%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如果 你遇到了一个问题。
  • 欢迎拉取请求。你可以帮助语言功能!

许可证

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
传递Java处理类类型参数的方式的参数   java安卓中间层admob在logcat中导致大量GC_FOR_ALLOC释放消息   java Vert。x Http请求未将参数分配为配置   java中多线程的输出不正确   如何减少java本地线程的冗余   java不完全分块结果   使用OpenCv时java中的Mat数据类型不受支持错误   Java中的正则表达式不工作,而同一正则表达式在shell中工作   java如何从数组中删除元素?   JDBCJava。sql。SQLException:[Microsoft][ODBC Microsoft Access驱动程序]操作必须使用可更新的查询   java如何以对角线打印字符串变量的字符?   SonarQube 5.2的java自定义插件生成NoClassDefFoundError   macos使用Java应用程序打开浏览器选项卡