一种简单但功能强大的文本插值模板语言,灵感来自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选择方法   连接到127.0.0.1的java间歇性故障,连接到IP(eth0)时没有故障   java如何优雅地杀死hadoop作业/intercept`hadoop作业杀死`   java如何通过引导类加载器以编程方式加载另一个类?   url Java:在查询参数之前使用片段构建URI   在BroadLeaf表blc_order_属性中保存OrderAttributes值时发生java错误   安卓将功能从xml转换为java   java如何将数据写入文件?   java JPA SQL结果映射   Java中整数对象比较运算符的引用安全性   Spring测试失败:java。lang.NoClassDefFoundError:org/springframework/cglib/transform/impl/memorysafuendecaredthrowableStrategy   rich:extendedDataTable中的java行选择和数据处理   java为什么我需要在volatile上对多个线程使用synchronized?   java尽管构建成功,但为什么会出现此错误?   数组$ArrayList不能转换为java。util。java中的ArrayList   java如何根据泛型类型调用方法?   java将JLabel添加到JPanel,将JPanel添加到JFrame   如果MapStruct中的源为null,则java将父目标设置为null   JavaJBossDrools从DRL插入事实   java不同的JRE安装(windows)