这也就意味着,我们需要设计一个模型语言。而它对于我们而言,实际上是领域特定语言(DSL)。如下是一个简单的 DSL 示例,用于描述使用到的组件:
{'style': '','id': 2,'blocks': [{'content': {'content': 'content','title': 'hello'},'type':'card'}] }
除此,我们还需要设计对应的布局 DSL,诸如于:
H:[circle1(circle1.height)] // set aspect-ratio for circle1HV:[circle2..5(circle1)] // use same width/height for other circlesH:|[circle1]-[circle2]-[circle3]-[circle4]-[circle5]|V:|~[circle1..5]~| // center all circles vertically
最后,我们还需要将流代码,转换为真实的项目代码。三种类型的 DSL 结合下来,都不是一个轻松的工具。