【发布时间】:2014-06-20 14:42:26
【问题描述】:
我创建了一个扩展类 BuilderSupport 的 groovy DSL,它现在看起来像这样:
def menu = new MenuBuilder().create {
item "something.label" : "something"
item "other.label" : "other"
item "asd.label": "asd", {
"test.label": "test"
}
}
create 并不是一个真正的函数,它只是根节点的标准名称,
item "X": "Y" 代表一个菜单项,其中 X 是它的标签,Y 是该项的目标控制器。
DSL 已经在工作了。我的问题是如何制作它,以便您可以简单地在单独的文件中指定 DSL,然后在 Grails 应用程序启动时加载它,类似于 Grails 的 Bean 的 DSL 和约束的 DSL。
该文件中将只有以下代码。
{
item "something.label" : "something"
item "other.label" : "other"
item "asd.label": "asd", {
"test.label": "test"
}
}
感谢您的关注
【问题讨论】: